PowerShell: Ping Host List from Text File

Here’s a quick PowerShell script to ping a list of hosts (computers, or other IP endpoints) from a text file. In addition, it eliminates error messages, which results in a filtered list of hosts that are alive. It runs quickly, because the ping count has been restricted to 1, from the default of 4.

Clear-Host
foreach ($Client in Get-Content -Path (Read-Host).Replace('"',''))
{
    Test-Connection -ComputerName $Client.Trim() -Count 1 -ErrorAction SilentlyContinue
}

The reason it has the call to the String.Replace() method is because, if you use the Copy as Path feature in Windows 7 Explorer to feed the input to the script, it includes double quotes around the path. In this script, we don’t actually need the double quotes, because that will confuse the Get-Content cmdlet’s –Path parameter.

The call the String.Trim() is present because in my test input text file, some computer names had whitespace after them; this call cleans that up.

ConfigMgr: You Receive Error 0×80070490 in a Capture Task Sequence

If you ever work with Operating System Deployment (OSD) in Microsoft’s System Center Configuration Manager (SCCM / ConfigMgr) 2007, you might build a task sequence that only performs an OS image capture (as opposed to an OS build & capture). You might think — logically — that you only need a single task sequence step to perform this action: a “Capture Operating System Image” step. Unfortunately, this isn’t the case. If you attempt to run a task sequence like this, you’ll probably receive a 0×80070490 error code, which means “element not found.”

image

Continue reading

ConfigMgr: Start the Console as a Different User

In the interest of security, some organizations provide administrative IT users with separate user accounts for administrative tasks. While this improves security, it often complicates day-to-day administrative tasks by requiring additional logins to various programs or remote systems. If you are a Microsoft System Center Configuration Manager administrator who is running the console on your administrative workstation (remote from the ConfigMgr provider), you can adjust your default Start Menu shortcut to the following command, which will always prompt you for your administrative password:

C:Windowssystem32runas.exe /user:domainMyAdminAccount "mmc "C:Program Files (x86)Microsoft Configuration Manager ConsoleAdminUIbinadminconsole.msc""

image

PowerShell: Update your ConfigMgr OSD Boot Images to WinPE 3.1

When you upgrade your boot images in Microsoft’s System Center Configuration Manager (SCCM / ConfigMgr) 2007 from WinPE 3.0 to WinPE 3.1, you must run the ExportDefaultBootImage() WMI method on the SMS_BootImagePackage WMI class for each boot image architecture. Typically this would simply include x86 (32-bit) and x64 (64-bit) boot images (Windows Image Format (WIM) files).

There are a few different methods of running this WMI method:

  • Manually through wbemtest
  • Using the VBscript scripting language
  • A PowerShell script

Since the first two methods have been covered already by other people, I will show an example of using Windows PowerShell to call the method. Simply replace the SCCMServer and SiteCode variables with the appropriate values, and WIM paths with your own, and run the script.

Clear-Host
$SccmServer = 'MySccmServer'
$SiteCode = '123'
$BootImageClass = [wmiclass]"\$SccmServerrootsmssite_$SiteCode`:SMS_BootImagePackage"

$WimFiles = @{
    'x86' = '\$SccmServerSMS_$SiteCodeOSDbooti386winpe.x86.3.1.wim' 
    'x64' = '\$SccmServerSMS_$SiteCodeOSDbootx64winpe.x64.3.1.wim'
}

$BootImageClass.ExportDefaultBootImage('x64' , 1, $WimFiles.x64)
$BootImageClass.ExportDefaultBootImage('x86' , 1, $WimFiles.x86)