LeVeilleur.net

Subscribe

Archive for the ‘Windows’

Exchange 2007 : Activate Anti-Spam

octobre 14, 2009 By: Christopher Keyaert Category: Serveur@Home, Windows No Comments →

Installing Exchange 2007 Anti-spam system

  • Close the EMC (Exchange Management Console).
  • Open the PowerShell and navigate using the following path: « Program Files\Microsoft\Exchange Server\Scripts ».
  • Run the « install-AntispamAgents.ps1″
  • Restart the « Microsoft Exchange Transport » service in order to apply configuration changes.
  • Open the Exchange Management Console, and on the Organization configuration list, select Hub Transport.
  • The « Anti-Spam » tab has been added to the Hub Transport properties.

http://www.petri.co.il/install-anti-spam-exchange-2007.htm

PowerShell : Users, Groups, Services, Shares

avril 16, 2009 By: Christopher Keyaert Category: Windows, powershell No Comments →

Hello tout monde,

Voici un nouveau script permettant de récupérer :

-Local Users
-Local Groups
-Local Services
-Shares (With Shares Permissions and Ntfs Security)
-Testing the existing of a particular reg Key

Bonne journée

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
########################
#Functions
########################
$arrExclude = "NT AUTHORITY\LocalService",
            "NT AUTHORITY\Local Service",
            "NT AUTHORITY\NETWORK SERVICE",
            "NT AUTHORITY\NetworkService",
            "LocalSystem",
            ".\ASPNET"

function checkExclusions([string]$strval)
    {
    foreach ($val in $arrExclude)
        {if ($val.ToLower() -eq $strval){return $true}  }
    return $false
    }

function Get-MySharePermissions
{
    param([string]$computername,[string]$sharename)
    $ShareSec = Get-WmiObject -Class Win32_LogicalShareSecuritySetting -ComputerName $computername
    ForEach ($ShareS in ($ShareSec | Where {$_.Name -eq $sharename}))
    {
        $SecurityDescriptor = $ShareS.GetSecurityDescriptor()
        $myCol = @()
        ForEach ($DACL in $SecurityDescriptor.Descriptor.DACL)
        {
            $myObj = "" | Select Domain, ID, AccessMask, AceType
            $myObj.Domain = $DACL.Trustee.Domain
            $myObj.ID = $DACL.Trustee.Name
            Switch ($DACL.AccessMask)
            {
                2032127 {$AccessMask = "FullControl"}
                1179785 {$AccessMask = "Read"}
                1180063 {$AccessMask = "Read, Write"}
                1179817 {$AccessMask = "ReadAndExecute"}
                -1610612736 {$AccessMask = "ReadAndExecuteExtended"}
                1245631 {$AccessMask = "ReadAndExecute, Modify, Write"}
                1180095 {$AccessMask = "ReadAndExecute, Write"}
                268435456 {$AccessMask = "FullControl (Sub Only)"}
                default {$AccessMask = $DACL.AccessMask}
            }
            $myObj.AccessMask = $AccessMask
            Switch ($DACL.AceType)
            {
                0 {$AceType = "Allow"}
                1 {$AceType = "Deny"}
                2 {$AceType = "Audit"}
            }
            $myObj.AceType = $AceType
            Clear-Variable AccessMask -ErrorAction SilentlyContinue
            Clear-Variable AceType -ErrorAction SilentlyContinue
            $myCol += $myObj
        }
    }
    Return $myCol
}

function Ping (  [string] $strComputer )
{
  $timeout=120;
  trap { continue; }

  $ping = new-object System.Net.NetworkInformation.Ping
  $reply = new-object System.Net.NetworkInformation.PingReply

  $reply = $ping.Send($strComputer, $timeout);
  if( $reply.Status -eq "Success"  )
  {
     return $true;
  }
  return $false;
}

########################
#Script
########################
$pathFolder = "D:\Reporting\ComputerPerm"
$computersList = get-content "$pathFolder\list.txt"
$ArrayUser = @()
$ArrayGroup = @()
$ArrayKey = @()
$ArrayService = @()
$ArrayShare = @()
$ArrayAccess = @()

foreach($computer in $computersList)
{

#################################################################################################
$retPing = Ping $computer
if($retPing -eq $true)
    {
    #Disabling the error on the screen
    $errorActionPreference="SilentlyContinue"
    $testAccss = get-wmiobject Win32_OperatingSystem -computername $computer -ErrorVariable ERR
        If($ERR)
            {$Access = $false}
        else{$Access = $true}
    }
else{$Access = $false}

if($Access -eq $false)
    {
    #Srv not ping or denied
    Write-Host "Server : " (($computer).trim()).ToUpper() " - Ping : $retPing - Access : $Access"
    $obj=New-Object PSObject
    $obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
    $obj | Add-Member Noteproperty -Name "PING" -Value $retPing
    $obj | Add-Member Noteproperty -Name "ACCESS" -Value $Access
    $ArrayAccess += $obj
    }
else{
    #Working on it

#################################################################################################
Write-Host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Write-Host ""
Write-host "ServerName : $computer"
Write-Host ""

#################################################################################################
Write-Host "***********************"
Write-Host "List local user account"
Write-Host "***********************"
Write-Host ""

$namespace = "root\CIMV2"
$usersList = Get-WmiObject -class Win32_UserAccount -computername $computer -namespace $namespace -filter "localaccount=true"

foreach($user in $usersList)
    {
    Write-host "Account Name : " $user.name
    Write-Host "Account Description : " $user.description
    Write-host "Disabled : " $user.disabled
    Write-Host ""

    $obj=New-Object PSObject
    $obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
    $obj | Add-Member Noteproperty -Name "AccountName" -Value (($user.name).trim()).ToUpper()
    $obj | Add-Member Noteproperty -Name "AccountDescription" -Value (($user.description).trim()).ToUpper()
    $obj | Add-Member Noteproperty -Name "Disabled" -Value $user.disabled
    $ArrayUser += $obj
    }

#################################################################################################
Write-Host "***********************"
Write-Host "List local Group"
Write-Host "***********************"
Write-Host ""

$results = Get-WmiObject -class Win32_Group -computername $computer -namespace $namespace -filter "localaccount=true"
foreach($result in $results)
    {
    Write-Host "Group Name : " $result.name
    Write-Host "Group Description : " $result.description
    Write-Host ""

    $GroupName = $result.name
    $group =[ADSI]"WinNT://./$GroupName"
    $members = @($group.psbase.Invoke("Members"))
    $list = $members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
    if($list -ne $null)
        {
        foreach($member in $list)
            {
            Write-host "Account Name : " $member.toupper()

            $obj=New-Object PSObject
            $obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "GroupName" -Value (($result.name).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "GroupDescription" -Value (($result.description).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "Member" -Value (($member).trim()).ToUpper()
            $ArrayGroup += $obj
            }
        }
    else
        {
        $obj=New-Object PSObject
        $obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
        $obj | Add-Member Noteproperty -Name "GroupName" -Value (($result.name).trim()).ToUpper()
        $obj | Add-Member Noteproperty -Name "GroupDescription" -Value (($result.description).trim()).ToUpper()
        $obj | Add-Member Noteproperty -Name "Member" -Value ""
        $ArrayGroup += $obj
        }

    Write-Host ""
    }

#################################################################################################
Write-Host ""
Write-Host "********************"
Write-Host "Testing Registry Key"
Write-Host "********************"
Write-Host ""

#Just for testing purpose
#$key = "SYSTEM\CurrentControlSet\Services\W32Time\Parameters"
$key = "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\AutoShareServer"
$type = [Microsoft.Win32.RegistryHive]::LocalMachine
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $computer)
$regKey = $regKey.OpenSubKey($key)

Write-Host "Key : $key"
if($regKey -eq $null)
    {Write-Host "Key Present : false";
    $keyVal = $false
    }
else{Write-Host "Key Present : true"
    $keyVal = $true
    }

$obj=New-Object PSObject
$obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
$obj | Add-Member Noteproperty -Name "Key" -Value (($key).trim()).ToUpper()
$obj | Add-Member Noteproperty -Name "KeyVal" -Value $keyVal
$ArrayKey += $obj  

#################################################################################################
Write-Host ""
Write-Host "**************************"
Write-Host "Service with local account"
Write-Host "**************************"
Write-Host ""

$results = gwmi win32_service -computer $Computer -property name, startname, caption
foreach ($result in $results)
    {
    $account = $result.StartName.ToLower()
    if ((checkExclusions $account) -eq $false)
        {
        Write-Host "Service : " $result.Name
        Write-Host "Caption : " $result.Caption
        Write-Host "Account : " $account
        Write-Host ""

        $obj=New-Object PSObject
        $obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
        $obj | Add-Member Noteproperty -Name "Service" -Value (($result.Name).trim()).ToUpper()
        $obj | Add-Member Noteproperty -Name "Caption" -Value $result.Caption
        $obj | Add-Member Noteproperty -Name "Account" -Value $account
        $ArrayService += $obj      

        }
    }

#################################################################################################
Write-Host ""
Write-Host "**************************"
Write-Host "Share on the computer"
Write-Host "**************************"
Write-Host ""
$results = get-WmiObject Win32_Share -computer $Computer
foreach ($result in $results)
    {
    Write-Host ""
    Write-Host "---------------"
    Write-Host ""
    Write-Host "Share Name : " $result.name
    Write-Host "Share Path : " $result.path
    Write-Host "Share Description : " $result.description
    Write-Host
    Write-Host "/!\Share Persmissions /!\"
    $shareInfos = Get-MySharePermissions $Computer $result.name
    $cpt= 1
    foreach($shareInfo in $shareInfos)
        {
        Write-Host "$cpt-Domain : " $shareInfo.domain
        Write-Host "$cpt-User : " $shareInfo.id
        Write-Host "$cpt-AccessMask : " $shareInfo.accessMask
        Write-Host "$cpt-AceType : " $shareInfo.AceType
        Write-Host ""
        Write-Host "/!\Ntfs Persmissions /!\"

        $path = "\\$computer\" + $result.name

        if($result.name -ne "IPC$")
            {
            $values = Get-Acl $path  | select-object path,owner,accesstostring,group
            foreach($value in $values)
                {
                Write-Host $value.path
                Write-Host $value.owner
                Write-Host $value.accesstostring
                Write-Host $value.group
                Write-Host ""

                $obj=New-Object PSObject
                $obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
                $obj | Add-Member Noteproperty -Name "ShareName" -Value (($result.name).trim()).ToUpper()
                $obj | Add-Member Noteproperty -Name "SharePath" -Value (($result.path).trim()).ToUpper()
                $obj | Add-Member Noteproperty -Name "ShareDescription" -Value $result.description
                $obj | Add-Member Noteproperty -Name "Domain" -Value $shareInfo.domain
                $obj | Add-Member Noteproperty -Name "User" -Value $shareInfo.id
                $obj | Add-Member Noteproperty -Name "AccessMask" -Value $shareInfo.accessMask
                $obj | Add-Member Noteproperty -Name "AceType" -Value $shareInfo.AceType
                $obj | Add-Member Noteproperty -Name "NTFSPath" -Value (($value.path).trim()).ToUpper()
                $obj | Add-Member Noteproperty -Name "NTFSOwner" -Value $value.owner
                $obj | Add-Member Noteproperty -Name "NTFSAccesstoString" -Value $value.accesstostring
                $obj | Add-Member Noteproperty -Name "NTFSGroup" -Value $value.group
                $ArrayShare += $obj
                }
            }
        else
            {
            $obj=New-Object PSObject
            $obj | Add-Member Noteproperty -Name "ServerName" -Value (($computer).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "ShareName" -Value (($result.name).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "SharePath" -Value (($result.path).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "ShareDescription" -Value $result.description
            $obj | Add-Member Noteproperty -Name "Domain" -Value $shareInfo.domain
            $obj | Add-Member Noteproperty -Name "User" -Value $shareInfo.id
            $obj | Add-Member Noteproperty -Name "AccessMask" -Value $shareInfo.accessMask
            $obj | Add-Member Noteproperty -Name "AceType" -Value $shareInfo.AceType
            $obj | Add-Member Noteproperty -Name "NTFSPath" -Value ""
            $obj | Add-Member Noteproperty -Name "NTFSOwner" -Value ""
            $obj | Add-Member Noteproperty -Name "NTFSAccesstoString" -Value ""
            $obj | Add-Member Noteproperty -Name "NTFSGroup" -Value ""
            $ArrayShare += $obj
            }

        $cpt+= 1
        }

    }
#################################################################################################

    #End test Access
    }

}

$ArrayUser | Export-Csv "$pathFolder\1-user.csv"
$ArrayGroup | Export-Csv "$pathFolder\2-group.csv"
$ArrayKey | Export-Csv "$pathFolder\3-RegKey.csv"
$ArrayService | Export-Csv "$pathFolder\4-Service.csv"
$ArrayShare | Export-Csv "$pathFolder\5-Share.csv"
$ArrayAccess | Export-Csv "$pathFolder\Access.csv"

PowerShell : List Cluster’s Resources

mars 30, 2009 By: Christopher Keyaert Category: Windows, powershell No Comments →

Voici un petit script PowerShell permettant de lister toutes les ressources disks des clusters.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$logFilePath = "D:\DashBoard\Inventory\source\Cluster\mylog.log"
$listFile = "D:\DashBoard\Inventory\source\Cluster\list.txt"
Start-Transcript -Path $logFilePath -Append >$null
$list = Get-Content $listFile
foreach($srv in $list)
    {
    $SrvName = $srv
    $c = new-object -comobject MSCLuster.Cluster
    $c.open($SrvName)
    #Cluster Name
    Write-Host "Cluster Name : " $c.name "`r"
    #Cluster Nodes
    foreach($node in $c.nodes)
        {
        Write-Host "Cluster Nodes : " $node.name "`r"
        }

    Write-Host "-----"  "`r"
    #Resources Groups

    foreach($resourceG in $c.resourceGroups)
        {
        Write-Host "Resource Group : " $resourceG.name "`r"
        foreach($r in $resourceG.Resources)
            {
            if($r.TypeName -like "*Physical Disk*")
                {Write-Host "Resource Name Disk Name : " $r.name "`r"}
            if($r.TypeName -like "*Network Name*")
                {Write-Host "Resource Name NetWork Name : " $r.name "`r"}
            }
        Write-Host "-----" "`r"
        }

    Write-Host "" "`r"
    Write-Host "***************************" "`r"
    Write-Host "" "`r"
    }

Stop-Transcript

VmWare Tools Installation Failed : Error 1722

décembre 18, 2008 By: Christopher Keyaert Category: Serveur@Home, Windows 2 Comments →

VmWare Toos Installation Failed : Error 1722

  1. Open registry editor, locate HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\COM3, and then delete this key.
  2. From the Start menu, point to Settings, click Control Panel, and then click Add/Remove Programs.
  3. Click Add/Remove Windows Components.
  4. Proceed through the wizard, and accept all of the defaults. (COM is reconfigured)
  5. Restart the computer.

After that, reinstallation of the tools :

  1. Create a directory (c:\vmtools)
  2. Mount the VMware Tools CD
  3. Copy VMware Tools.msi to the directory you created
  4. Copied the VCBRequested.dll and VCBSnapshotProvider.dll from vmware tools cd\program files\VMware\VMware Tools\Drivers\vss\Win2003 to the directory your created
  5. Cancel the VMware tools installation that has started itself
  6. Using 7Zip ( http://www.7zip.org/) I extracted the VMware Tools.msi file (rightclick on the MSI, Open Context Menu for 7-Zip, selected Extract to VMware Tools
  7. Now within the c:\vmtools directory you will have VMware Tools Folder
  8. Within the VMware Tools Folder there will be a file Binary.ComReg.exe, take a copy of this a place it somewhere within the %path% – say c:\windows\ and rename it ComReg.exe
  9. Now create the following path c:\program files\VMware\VMware Tools\Drivers\vss
  10. Copy both the VCBRequested.dll and VCBSnapshotProvider.dll from the folder you created in step one to the path you created at step 8
  11. Now run the following command :
     comreg.exe -register "c:\Program Files\VMware\VMware Tools\Drivers\vss\VCBSnapshotProvider.dll" "VMware Snapshot Provider" "vmvss" "VMware Snapshot Provider"
  12. Finally, run the Vmware Tools install process, and this time it should work

SCOM2007 : Jalasoft Xian Io for VmWare Monitoring

novembre 26, 2008 By: Christopher Keyaert Category: Scom 2007, Windows No Comments →

Now monitor your network devices and Unix servers directly in System Center Operations Manager 2007 with the latest version of Xian Network Manager! Advanced new features like, device update, network scan task, linkable policy templates are only a few of the many new features in Xian Io. Check out more information and download the free evaluation version to see the power of Xian yourself.

It is possible that your VC is v2.5, our Virtual Center SMP does not support that version by default, but we have developed a patch in order to provide support for this version. Just follow these steps in order to apply it:

1. Download the patch from: http://download.jalasoft.com/pub/patches/JS0176TD/Patch20080711.zip
2. Go to the server where Xian was deployed and stop the ‘Jalasoft Xian Network Manager’ service.
3. Go to the following folder: ‘[program files]\Jalasoft\Xian Network Manager Io\Plugins\Jalasoft.Xian.Plugin.VMwareVirtualCenter\resources\’
4. Replace the ‘Jalasoft.Xian.Plugin.VMwareVirtualCenter.config.xml’ file with the recently downloaded.
5. Start the ‘Jalasoft Xian Network Manager Server’ service.
6. Open the Xian console and try discovering your virtual centers. Please note that discovering a VC could take several time (depending on the amount of ESX servers hosted in it), so it is recommended to increase the ‘timeout’ and  ‘maximum number of retries’ parameters on the execution of the discovery rule.