30
Jul/09
2

Ping and verify access to multiple Computers in AD

Here’s a Powershell script that queries Active Directory for Computers and then starts to Ping them and tries to access the C$ Share on each Computer. Finally it generates an Excel sheet with the Result.
Note: If you’d like to check for access rights, run the script using an Account that should have access rights on the Client Computers.

Modify the Directory entry path to suit your environment.

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
trap [System.Management.Automation.MethodInvocationException]{
    write-host ("ERROR: " + $_) -Foregroundcolor Red;
	Continue
	}
 
$erroractionpreference = "SilentlyContinue"
 
$strCategory = "computer"
 
$objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=Laptops,OU=Computers,dc=yourdomain,dc=com")
 
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=$strCategory)")
 
$colProplist = "name","description"
foreach ($i in $colPropList) {
    $objSearcher.PropertiesToLoad.Add($i)
    }
 
$colResults = $objSearcher.FindAll()
$count = 1
$total = $colResults.count
$arrComputers = @{}
 
 
 
foreach ($strComputer in $colResults) {
    $ping = new-object System.Net.NetworkInformation.Ping
    $name = $strComputer.Properties.name
    $description = $strComputer.Properties.description
 
	write-progress -id 1 -activity  "Checking Computer $name $description ($count / $total )" -status "Getting IP address" #-percentComplete 
 
	Try {
	$ip = ([System.Net.Dns]::GetHostAddresses("$name"))
 
	write-progress -id 1 -activity  "Checking Computer $name $description ($count / $total )" -status "IP: $ip" 
 
	sleep 1
	}
	Catch {
	    echo "Cannot handle the error: $_"
    	#throw $_
	}
 
	write-progress -id 1 -activity  "Checking Computer $name $description ($count / $total )" -status "Pinging" #-percentComplete 
 
	Try {
	$Reply = $ping.send($strComputer.Properties.name)
	}
	Catch {
		$Reply = "Failed"
	    echo "Cannot handle the error: $_"
    	#throw $_
	}	
 
    if ($Reply.status –eq “Success”) {
		write-progress -id 1 -activity  "Checking Computer $name $description ($count / $total )" -status "Checking Access"
        if (Test-Path "\\$name\C$") {
			$arrComputerAccess += $strComputer.Properties.name
			}
		else {
			$arrComputerPing += $strComputer.Properties.name
			}		
        }
    else {
    $arrComputerOffline += $strComputer.Properties.name
    }
    $Reply = ""
    $count ++
    }
 
$a = New-Object -comobject Excel.Application
$a.visible = $True 
 
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
 
$c.Cells.Item(1,1) = "Machine Name"
$c.Cells.Item(1,2) = "Ping Status"
$c.Cells.Item(1,3) = "Access Check"
 
$d = $c.UsedRange
$d.Interior.ColorIndex = 48
$d.Font.ColorIndex = 1
$d.Font.Bold = $True
#$d.EntireColumn.AutoFit($True)
 
$intRow = 2
 
foreach ($Computer in $arrComputerOffline)
{
$c.Cells.Item($intRow, 1) = $Computer.ToUpper()
$c.Cells.Item($intRow, 2) = "Offline"
$intRow ++
}
 
foreach ($Computer in $arrComputerPing)
{
$c.Cells.Item($intRow, 1) = $Computer.ToUpper()
$c.Cells.Item($intRow, 2) = "Online"
$c.Cells.Item($intRow, 3) = "Failed"
$intRow ++
}
 
foreach ($Computer in $arrComputerAccess)
{
$c.Cells.Item($intRow, 1) = $Computer.ToUpper()
$c.Cells.Item($intRow, 2) = "Online"
$c.Cells.Item($intRow, 3) = "Passed"
$intRow ++
}
 
$d.EntireColumn.AutoFit()
Print This Post
(6 votes, average: 3.50 out of 5)
Loading ... Loading ...
638 views
26
Jul/09
2

Renew expired Exchange 2007 Certificate

If your Exchange Certificate expires after 1 year of duty, you’ll probably notice many unhappy faces trying to rip you apart every morning. Users will receive Certificate Warnings when opening Outlook or using Outlook Web Access.
In addition, you get the following events on the Exchange 2007 Server:

Log Name: Application
Source: MSExchangeTransport
Date: 4/14/2009 2:10:22 PM
Event ID: 12015
Task Category: TransportService
Level: Warning
Keywords: Classic
User: N/A
Computer: MSX2K7
Description:
An internal transport certificate expired. Thumbprint:A0F32351EC29C1451B43CF7438AA1A4E147EA54D

Here’s what you need to do (Step by step):

Open the Exchange 2007 Management Shell and type:

Get-ExchangeCertificate | List
To receive a List of Certificates installed

New-ExchangeCertificate
To create a new Exchange Certificate

Enable-ExchangeCertificate -Thumbprint 57540C16F16C941CCB761079A5FC3402F34A3F69 -Service IIS
To Enable the new Certificate on the IIS Service (You can see the Thumbprint of your newly created certificate after you execute the “New-ExchangeCertificate” command. Replace this Thumbprint above with your own)

Remove-ExchangeCertificate -Thumbprint A0F32351EC29C1451B43CF7438AA1A4E147EA54D
And finally remove the old Certificate from the store

Print This Post
(10 votes, average: 4.20 out of 5)
Loading ... Loading ...
3,631 views
26
Jul/09
0

Update CustomSettings.ini and Bootstrap.ini on remote Deployment Points

When it comes down to only change Custom Settings or Bootstrappers on Distribution Points the “Update Deployment Point” command is definitely not your friend, since it does an xcopy from your whole Distribution Share to the Deployment point.
This little PowerShell code will update all Deployment Points with their corresponding CustomSettings.ini and Bootstrap.ini files located on the Master Server.

Make sure to change the $DistributionSourceServer variable to match your LAB Server

Note: I added a choice for additional purposes like updateing the unattended.txt file. The Script is not finished yet.

?View Code POWERSHELL
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
$DistributionSourceServer = "\\MDTSERVER\Distribution$"
 
Function Parse-IniFile ($file) {
	$ini = @{}
	switch -regex -file $file {
	    "^\[(.+)\]$" {
	      $section = $matches[1]
	      $ini[$section] = @{}
	     }
	    "(.+)=(.+)" {
	      $name,$value = $matches[1..2]
	      $ini[$section][$name] = $value
	    }
	  }
	  $ini
	}
 
Function Update-CustomSettings {
 
	$FolderList = get-ChildItem $DistributionSourceServer\Control -filter *-*
 
	foreach ($Folder in $FolderList) {
		$iniValue 		= Parse-IniFile -file $DistributionSourceServer\Control\$Folder\Bootstrap.ini
		$CurrentServer 	= $iniValue["Default"]["DeployRoot"]
		$SrcFolder 		= $DistributionSourceServer + "\Control\" + $Folder
		$DstFolder 		= $CurrentServer + "\Control"
 
		Write-Host "Updating " -NoNewline -ForegroundColor "White"
		Write-Host $DstFolder -ForegroundColor "Red"
 
		Copy-Item -Path $SrcFolder\Bootstrap.ini -Destination $DstFolder -Force -ErrorAction SilentlyContinue
		Copy-Item -Path $SrcFolder\CustomSettings.ini -Destination $DstFolder -Force -ErrorAction SilentlyContinue
		}
}
 
switch (Read-Host '
	[1] Update Customsettings.ini Files on Remote Servers
	[2] Synchronize Unattend.txt Files
	[3] Synchronize Applications
	') {
	1 {Update-CustomSettings; break}
	2 {'chose 2'; break}
	3 {'chose 3'; break}
	default {$null}
	}
Print This Post
(1 votes, average: 5.00 out of 5)
Loading ... Loading ...
701 views
26
Jul/09
0

Quest PowerShell Management Shell (Freeware)

The Quest Management Shell Provides very useful cmdlets to manage Objects in Active Directory. The ActiveRoles Management Shell for Active Directory is a set of PowerShell commands that can be used to perform and automate administrative tasks like discovering the AD environment, changing user properties, modifying group membership, provisioning new user accounts, and performing multiple other tasks within Active Directory.

Download: quest.com

QuestPS

Print This Post
(No Ratings Yet)
Loading ... Loading ...
288 views
26
Jul/09
0

PowerGUI (Freeware)

PowerGUI is a very nice tool that allows you to generate Powershell Scripts based on an Object Browser. It provides several interfaces such as VMWare Infrastructure Management, Microsoft Active Directory, Microsoft Exchange, Hyper-V and many more.

PowerGUI is the tool administrators need to rapidly adopt PowerShell within their environment. Immediately begin building powerful scripts that harness the power of PowerShell across your environment.  

Download: PowerGUI

PowerGUI

PowerGUI

PowerGUI Script Editor

PowerGUI_ScriptEditor

PowerGUI Code Generator

PowerGUI_CodeGenerator

Print This Post
(1 votes, average: 4.00 out of 5)
Loading ... Loading ...
308 views