Additional Dell Right-Click Tools

 

Previously, I posted how to Integrate Dell iDRAC into Configmgr 2012. Here are additional Dell right-click tools that can be leveraged with ConfigMgr 2012:

  • Show System and Warranty Information – Launches a Dell Web page based on the computer service tag and displays system details as well as factory warranty information.
  • Dell and System Center – Launches the Dell and System Center home page.
  • Dell TechCenter – Launches the home page for Dell and ConfigMgr on Dell TechCenter.

DellRClick

Perform the following steps to add the additional Dell Extensions:

  1. Close any existing instances of the ConfigMgr Console.
  2. Download LaunchDelliDracV2.  Extract both .ps1 files and copy to C:\PowerShell\CM12RClickTools\
  3. Extract Dell.XML from the downloaded .zip and copy to “C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\3fd01cd1-9e01-461e-92cd-94866b8d1f39\Dell.xml,” (you may need to create the Actions and GUID folder or replace the file created previously).
  4. Copy that same Dell.xml to C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\ed9dee86-eadd-4ac8-82a1-7234a4646e62\ (you may need to create the Actions and GUID folder).
  5. Launch the ConfigMgr console.
  6. Navigate to a device, right-click and view the additional actions from the Dell menu.

PowerShell for DellLaunchSystemInfo.ps1 (Hover and select ‘View Source’ to copy code):

$ComputerName = $args[0]
$SiteServer = $args[1]
$SiteNamespace = $args[2]
"Querying {0} for {1} Service Tag" -f $SiteServer, $ComputerName
$SysInfo  = get-wmiobject -ComputerName $SiteServer -Namespace $SiteNamespace -query "select SMS_G_System_PC_BIOS.SerialNumber from  SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_PC_BIOS on SMS_G_System_PC_BIOS.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Name = '$ComputerName' and SMS_G_System_SYSTEM_ENCLOSURE.Manufacturer like 'Dell%'"
if (($SysInfo -ne $null) -and ($SysInfo.SerialNumber.ToString().length -ge 5)) {
"Service Tag is {0}" -f $SysInfo.SerialNumber
$strURL = "http://www.dell.com/support/troubleshooting/us/en/19/Servicetag/"+ $SysInfo.SerialNumber
start $strURL
Start-Sleep 5
}
else {
write-host  "Dell Service Tag not found. Ensure the following:" -foregroundcolor red
write-host "Healthy Client" -foregroundcolor red
write-host "Running on PowerEdge Server" -foregroundcolor red
write-host "OMSA is installed on server" -foregroundcolor red
write-host "ConfigMgr inventorying Remote Access Service Port" -foregroundcolor redstart-sleep 60
}

PowerShell for DellLaunchiDRAC.ps1 (Hover and select ‘View Source’ to copy code):

$ComputerName = $args[0]
$SiteServer = $args[1]
$SiteNamespace = $args[2]
"Querying {0} for {1} DRAC URl" -f $SiteServer, $ComputerName
$DRACInfo  = get-wmiobject -ComputerName $SiteServer -Namespace $SiteNamespace  -query "select SMS_G_System_DELL_RemoteAccessServicePort.AccessInfoIPV4 from  SMS_R_System inner join  SMS_G_System_DELL_RemoteAccessServicePort on SMS_G_System_DELL_RemoteAccessServicePort.ResourceId =  SMS_R_System.ResourceId where SMS_R_System.Name = '$Computername'"
if (($DRACInfo -ne $null) -and ($DRACInfo.AccessInfoIPv4.ToString().length -ge 5) ) {
"Address is {0}" -f $DRACInfo.AccessInfoIPV4
start $DRACInfo.AccessInfoIPV4
Start-Sleep 5
}
else {
write-host "DRAC IP not found. Ensure the following:" -foregroundcolor red
write-host "Healthy Client" -foregroundcolor red
write-host "Running on PowerEdge Server" -foregroundcolor red
write-host "OMSA is installed on server" -foregroundcolor red
write-host "ConfigMgr inventorying Remote Access Service Port" -foregroundcolor red
start-sleep 60
}

XML for updated Dell.xml file (Hover and select ‘View Source’ to copy code):

<ActionDescription Class="Group" DisplayName="Dell" MnemonicDisplayName="Dell" Description="Dell Actions">
<ShowOn>
	<string>DefaultHomeTab</string><string>ContextMenu</string>
</ShowOn>
<ActionGroups>
	<ActionDescription Class="Executable" DisplayName="Launch iDRAC" MnemonicDisplayName="Launch iDRAC" Description = "Launch iDRAC in Web Browser" RibbonDisplayType="TextAndSmallImage">
		<ShowOn>
			<string>ContextMenu</string>
			<string>DefaultHomeTab</string>
		</ShowOn>
		<Executable>
			<FilePath>PowerShell.exe</FilePath>
			<Parameters>-ExecutionPolicy RemoteSigned -File C:\PowerShell\CM12RClickTools\DellLaunchiDRAC.ps1 "##SUB:Name##" "##SUB:__Server##" "##SUB:__Namespace##"  </Parameters>
		</Executable>
	</ActionDescription>
	<ActionDescription Class="Executable" DisplayName="Show System and Warranty Information" MnemonicDisplayName="Show System and Warranty Information" Description = "Show System and Warranty Information in Web Browser" RibbonDisplayType="TextAndSmallImage">
	<ShowOn>
		<string>ContextMenu</string>
		<string>DefaultHomeTab</string>
	</ShowOn>
	<Executable>
		<FilePath>PowerShell.exe</FilePath>
		<Parameters>-ExecutionPolicy RemoteSigned -File C:\PowerShell\CM12RClickTools\DellLaunchSystemInfo.ps1 "##SUB:Name##" "##SUB:__Server##" "##SUB:__Namespace##"  </Parameters>
	</Executable>
	</ActionDescription>
	<ActionDescription Class="Executable" DisplayName="Dell and System Center" MnemonicDisplayName="Dell and System Center" Description = "Launch Dell-System Center Integration Home Page" RibbonDisplayType="TextAndSmallImage">
	<ShowOn>
		<string>ContextMenu</string>
		<string>DefaultHomeTab</string>
	</ShowOn>
	<Executable>
		<FilePath>http://www.dell.com/systemcenter</FilePath>
		<Parameters></Parameters>
	</Executable></ActionDescription>
	<ActionDescription Class="Executable" DisplayName="Dell TechCenter" MnemonicDisplayName="Dell TechCenter" Description = "Launch Dell TechCenter to ConfigMgr Home Page" RibbonDisplayType="TextAndSmallImage">
	<ShowOn>
		<string>ContextMenu</string>
		<string>DefaultHomeTab</string>
	</ShowOn>
	<Executable>
		<FilePath>http://www.dell.com/ConfigMgr</FilePath>
		<Parameters></Parameters>
	</Executable></ActionDescription>
</ActionGroups>
</ActionDescription>

Get-CMSite – List all Primary and Secondary Sites

After launching your ConfigMgr 2012 SP1 PowerShell Command Prompt, use the Get-CMSite cmdlet to list all primary and secondary sites in a hierarchy. Since this is a GET verb, everything we do here is query-only, so there is no damage by running any of the examples below.
Examples:

get-cmsite – default arguments, will list all sites as follows:

get-cmsite-sample1

Command Action
get-cmsite | out-gridview Lists all sites to a gridview
get-cmsite | where-object {$_.type -eq 4} List the CAS
get-cmsite | where-object {$_.type -eq 2} List all Primary Sites
get-cmsite | where-object {$_.type -eq 1} List all Secondary Sites
get-cmsite | select-object ServerName, Version | sort-object Servername Lists all sites and version, sorted by servername
get-cmsite | where-object {$_.ReportingSiteCode -eq ”AMR” -and $_.Type -eq 1} List all secondary sites assigned to AMR
get-cmsite | select-object ServerName, Version | sort-object Servername | export-csv c:\temp\MySiteServers.csv -notypeinformation Same as previous, but exports to CSV file
get-cmsite | foreach {Get-WmiObject -class Win32_OperatingSystem -computer $_.ServerName | Select-Object __SERVER,@{label=’LastRestart’;expression={$_.ConvertToDateTime($_.LastBootUpTime)}}} Display last bootup time for each server-performs a WQL query on win32_OperatingSystem, so you must have proper rights to remotely connect to each system.

Happy Scripting!
Greg

PowerShell and ConfigMgr – List ConfigMgr cmdlets

Now that you’ve learned how to prepare your environment, let’s view all the cmdlets that are currently available for ConfigMgr. From your PowerShell prompt (that already has the ConfigMgr module imported), type the following:

get-command -module ConfigurationManager | out-gridview

This will display all cmdlets in the ConfigurationManager module. As of this writing (ConfigMgr 2012 SP1 Beta) there are 338 cmdlets. Here’s an example for how to get the current count:

get-command -module ConfigurationManager | measure-object

Notice the verb-noun pair for each cmdlet. By using this standard practice, Powershell enables you to 1) think, 2) type, 3) do. The goal is for the admin to use standard verbs to be able to easily leverage PowerShell with different products. (Review the approved verbs for Windows PowerShell). Type get-cm and then press [tab] multiple times to enumerate the ConfigMgr cmdlets. You can also type get-cmmanagementpoint and press [tab] multiple times to display all get commands for ConfigMgr Management Points.

Greg

ConfigMgr and PowerShell-Preparing Your Environment – Part II

Yesterday, we walked through the process of launching PowerShell from the ConfigMgr console as well as importing the ConfigMgr module from the PowerShell command line.  Here’s a little additional information so that you can create a shortcut to easily launch to that PowerShell command prompt for ConfigMgr, and automatically connect to the desired site.

First, create a file called C:\PowerShell\LaunchCM.ps1 with the following contents:

import-module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' -force
if ((get-psdrive LAB -erroraction SilentlyContinue | measure).Count -ne 1) {
new-psdrive -Name "LAB" -PSProvider "AdminUI.PS.Provider\CMSite" -Root "MyLABServer.Ramseyg.com"
}
cd LAB:

Replace “LAB” with the proper site code, and “MyLabServer.Ramseyg.Com” with the FQDN to the site (or SMS provider).

Next create a new shortcut with the following target:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noexit -executionpolicy Unrestricted -file C:\PowerShell\LaunchCM.ps1

This will launch an unrestricted PowerShell command prompt, loaded to your desired ConfigMgr site. As an added bonus, you can modify the shortcut properties (click the Advanced button) to configure the shortcut to always run as administrator.

Happy Scripting!

Greg

ConfigMgr and PowerShell-Preparing Your Environment

ConfigMgr 2012 SP1 contains almost everything you need to get started with PowerShell and the new ConfigMgr cmdlets. When you install an Admin console (whether local to the site server or on a remote console), you will see the following option to launch PowerShell with ConfigMgr integration:

Note that you must have the ConfigMgr Admin Console installed on the system where you plan to leverage the new cmdlets. Also, be sure to install the Windows Management Framework 3.0 before you attempt to use PowerShell integration with ConfigMgr.

You can launch a PowerShell Prompt from the image displayed above, and it will automatically load the ConfigMgr module, connected to the site code of the site loaded in the admin console. If you prefer to use the Powershell module without the need to launch from the admin console (recall that  you must have the console installed in order to use the module), perform the following steps:

  1. Open an x86 PowerShell Prompt (when possible, use Run As Administrator)
  2. Run the following command: Import-Module “C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1″  (modify the path as required for your console installation).
  3. Verify the module is enabled by running following command: get-command -module ConfigurationManager This will show all commands available from the ConfigMgr 2012 PowerShell Module (as of this post, there are 338 cmdlets in ConfigMgr 2012 SP1 Beta). If you see the ConfigMgr cmdlets, you’re ready to move to the next level! (If you don’t, be sure you launched the x86 version of PowerShell on x64 systems).
  4. You can then use get-psdrive cmdlet to list the available drives. Notice in the image below that CEN is the site code of my site, and CMSite is the provider.
  5. As shown in the image, simply type cd cen: to navigate to the PowerShell Provider for ConfigMgr site CEN.
  6. Verify you’re connected to the provider by running the following command: get-cmsite This will list all primary and secondary sites in the hierarchy.

As a best practice, always perform admin functions from the central site. However, if you have multiple primary sites (and a CAS), you may need to connect to additional sites (by default, you will automatically connect to the most recently used site server from the Admin Console). Run the following PowerShell command to connect to the site S01:

new-psdrive -Name "S01" -PSProvider "AdminUI.PS.Provider\CMSite" -Root "MySiteServer.FQDN.COM" -Description "S01 Primary Site"

(Replace “S01″ with your site code, “MySiteServer.FQDN.COM” with the FQDN to the provider, and “S01 Primary Site” with a description of the site).

Happy Scripting!

Greg

How To: Display all Methods for All Classes in a WMI Namespace using PowerShell

Yes, that title is a bit cryptic – if you’ve worked a bit in WMI with PowerShell, you’ll see this code and (hopefully) think “Cool.” If you’re new to PowerShell and/or WMI, well, hang on to your hat, we’ll start diving into these soon to see how we can use them.

This example command displays all methods under the root\ccm\clientsdk namespace – this is a namespace that you will find on all ConfigMgr 2012 clients.

get-wmiobject -namespace root\ccm\clientsdk -list | select __Path -Expand Methods | select Origin, Name, __Path | out-gridview

Greg

How to: Query MachineOU information from ConfigMgr using PowerShell

With the Application Model in ConfigMgr 2012, you can create requirement rules based on Machine OU. Here’s a quick script to see what the ConfigMgr 2012 client has stored as the Machine OU:

( gwmi global_machineOU -namespace root\ccm\cimodels).MachineOU

Happy Scripting!

Greg

ramseyg@hotmail.com

How to: Exectue a ConfigMgr 2012 Auto Deployment Rule (ADR)

Here’s a quick example for how to initiate an ADR using PowerShell:

(gwmi sms_autodeployment -namespace root\sms\site_cas -computer MyServer -filter "Name='FEP Updates'").EvaluateAutoDeployment()

Replace CAS with your site code, and MyServer with the server name. My ADR is “FEP Updates”, so replace that with the desired ADR to run. Remember that ADRs are dependent on the WSUS synchronization, so if you re-evaluate the ADR without a new WSUS synchronization, you may not see any change in your ADR.

If you really want to party, and desire to re-run all ADRs, run the following command:

gwmi sms_autodeployment -namespace root\sms\site_cas -computer MyServer | foreach-object {$_.EvaluateAutoDeployment()}

This will find all ADRs, and call the EvaluateAutoDeployment method on each one.
Happy Scripting,

Greg

ramseyg@hotmail.com

Converting to/from WMI Date Time

You will find many posts for how to convert a wmi date-time string to a human-friendly date time here’s one example from Don Jones.

First, here’s an example of the wmi date-time string:

Get-WmiObject -class Win32_OperatingSystem  | select __Server, LastBootUpTime

The value for LastBootUpTime will look something like this: 20120718141700.473048-300. This output is very handy for alpha-sort, by the way…
And Here’s Don’s code:

Get-WmiObject -class Win32_OperatingSystem | Select-Object __SERVER,@{label='LastRestart';expression={$_.ConvertToDateTime($_.LastBootUpTime)}}

Notice how Don elegantly converts the string on the fly with the label and expression arguments.

Now here’s an example of using a COM object to convert the current date time to a wmi date-time string.

$wmidate = new-object -com Wbemscripting.swbemdatetime
$date = get-date -format g
$wmidate.SetVarDate($date,$true)
$wmidate.value

Not nearly as elegant, but it gets the job done. When you create objects in ConfigMgr that require a date-time field, you will usually enter a wmi date-time string.

 

Happy Scripting!

 

Greg

 

How To: List Task Sequence Environment Variables and Values

(another encore presentation from my old blog site…)

From the TechNet forums, this is an example for how to display Task Sequence Environment Variables and Values using VBScript:

Set oTSEnv = CreateObject(“Microsoft.SMS.TSEnvironment”)
For Each oVar In oTSEnv.GetVariables
WScript.Echo oVar & “=” & oTSEnv(oVar)
Next

You could save those two lines of code to “ShowTSVars.vbs”, and then when you want, simply run “cscript //nologo ShowTSVars.vbs >vars.txt” to write all variables to vars.txt.

Follow

Get every new post delivered to your Inbox.

Join 1,045 other followers