How To: Initiate the “Validate” Action on all DPs for a Package in ConfigMgr 2012

ConfigMgr 2012 has a feature that allows you to validate content of a distribution point on a schedule, which works great for normal business. However, if you encounter an issue on a package and need to validate content immediately for each DP, it does require a bit of effort, as you have to go to the object in question, view the properties, then on the Content Locations tab, select a DP and click “Validate” – rinse and repeat–you must do this for each DP  to validate content, as described in the documentation. This post will describe how to enable a right-click option on any content in the Monitoring tab of the admin console.

validatecontent_2

You can download the .zip file and follow the directions in the included ‘info.txt’ file for a fast deployment to your admin console. You can review additional details below.

First you must create the proper r-click context menu. Copy the following .xml, save it as “ValidateContent.xml”, and copy it to C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\14214306-59f0-46cf-b453-a649f2a249e1\ValidateContent.xml. (Adjust the path as appropriate to your ConfigMgr Admin Console installation path).

<ActionDescription DisplayName="Validate Content on All DPs" MnemonicDisplayName="Validate Content on All DPs" Description = "Validate Content on All DPs" RibbonDisplayType="TextAndSmallImage">
<ShowOn>
<string>ContextMenu</string>
<string>DefaultHomeTab</string>
</ShowOn>
<Executable>
<FilePath>PowerShell.exe</FilePath>
-ExecutionPolicy RemoteSigned -File C:\PowerShell\CM12RClickTools\ValidatePackage.ps1 "##SUB:__Server##" "##SUB:__Namespace##" "##SUB:PackageID##"
</Executable>
</ActionDescription>

Notice in the .xml we specify the -ExeuctionPolicy RemoteSigned parameter. Best practice would be to sign your scripts, but if that’s not something you can manage easily, you can use the parameter as shown to modify the execution policy for the specific instance you’re launching, instead of changing the execution policy for all script execution. Next, copy the PowerShell code below, and save it to C:\PowerShell\CM12RClickTools\ValidatePackage.ps1 (although it’s named ValidatePackage, it does work for all content–Application, OS Image, Package, etc).

#capturing arguments:
$SiteServer = $args[0]
$SiteNamespace = $args[1]
$SiteCode = ($args[1]).Substring(14)
$PackageID = $args[2]

"{0} {1} {2} {3}" -f $SiteServer, $SiteNamespace, $SiteCode, $PackageID

$myFilter = "PackageID='$PackageID'"

$dps = gwmi sms_distributionpoint -namespace $SiteNamespace -ComputerName $SiteServer -filter $myFilter

if (($dps | measure-object).Count -ge 1) {
$dps | % {
"Initiating 'Validate Content' on {0}..." -f $_.ServerNALPath
if ($env:Computername -eq $SiteServer) {  #if running directly on the site server, omit the -computername argument

invoke-cimmethod -ClassName sms_distributionPoint -namespace $SiteNamespace -methodname "VerifyPackage" -arguments @{ PackageID=$_.PackageID; Nalpath=$_.ServerNALPath}
}
else {
invoke-cimmethod -ClassName sms_distributionPoint -namespace $SiteNamespace -ComputerName $SiteServer -methodname "VerifyPackage" -arguments @{ PackageID=$_.PackageID; Nalpath=$_.ServerNALPath}
}
}
"Validation initiated - Review Content Status for more information."
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

}
else {
"0 DPs found with this package. Content must be distributed in order to validate."
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

}

Now re-launch your ConfigMgr Admin console to use the new r-click->Validate Content on All DPs feature. As you can see from the code, this scritpt uses WMI, as SP1 does not contain cmdlets to perform this action. We use the Get-WMIobject (gwmi) cmdlet for the SMS_DistributionPoint class, filtered to only receive DPs for the desired PackageID. We then execute the VerifyPackage method for each DP.

**Important note: As of ConfigMgr 2012 SP1, only content in the content library (single instance store) will be validated. There is currently no ability to verify content on a package share (e.g. \\mydp\smspkgd$\CAS00023\).

For more information about Content Validation:

Happy Scripting!

Greg
ramseyg@hotmail.com

How To: Send Content to DP Group from Monitoring Node in ConfigMgr 2012 SP1

This post will demonstrate how to create a right-click action on the Monitoring->Distribution Status->Content Status tab to send content to a DP group. Sometimes when troubleshooting an issue, I realize that the content was sent to one DP for testing, and then promoted to production. The out-of-box experience requires you navigate back to the object (package, software update, application, etc) and then send content to DPs. This right-click tool will save you several clicks.

sendtodpgroup

After selecting to “Send to DP Group”, you will see a PowerShell window with a prompt to choose the desired DP Group.

sendtodpgroup-2

Of course, you could create multiple right-click items with hard coded DP Groups and actions, but for this post, we’ll use the dynamic selector shown above.

You can download the .zip file and follow the directions in the included ‘info.txt’ file for a fast deployment to your admin console. You can review additional details below.

First you must create the proper r-click context menu. Copy the following .xml, save it as “SendToDPGroup.xml”, and copy it to C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\14214306-59f0-46cf-b453-a649f2a249e1\SendToDPGroup.xml. (Adjust the path as appropriate to your ConfigMgr Admin Console installation path).

<ActionDescription DisplayName="Send to DP Group" MnemonicDisplayName="Send to DP Group" Description = "Send package to a DP group." RibbonDisplayType="TextAndSmallImage">
<ShowOn>
<string>ContextMenu</string>
<string>DefaultHomeTab</string>
</ShowOn>
<Executable>
<FilePath>PowerShell.exe</FilePath>
-ExecutionPolicy RemoteSigned -File C:\PowerShell\CM12RClickTools\SendToDPGroup.ps1 "##SUB:__Server##" "##SUB:__Namespace##" "##SUB:PackageID##" "##SUB:ObjectTypeID##" "##SUB:SoftwareName##"
</Executable>
</ActionDescription>

Notice in the .xml we specify the -ExeuctionPolicy RemoteSigned parameter. Best practice would be to sign your scripts, but if that’s not something you can manage easily, you can use the parameter as shown to modify the execution policy for the specific instance you’re launching, instead of changing the execution policy for all script execution. Next, copy the PowerShell code below, and save it to C:\PowerShell\CM12RClickTools\SendToDPGroup.ps1

#capturing arguments:
$SiteServer = $args[0]
$SiteNamespace = $args[1]
$SiteCode = ($args[1]).Substring(14)
$PackageID = $args[2]
$objectTypeID = $args[3]
$SoftwareName = $args[4]
$SiteDrive = $sitecode + ":"

"{0} {1} {2} {3} {4} {5}" -f $SiteServer, $SiteNamespace, $SiteCode, $PackageID, $objectTypeID, $SoftwareName

#Connect to PowerShell Provider:
$ModulePath = (($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + '\ConfigurationManager.psd1'
"Connecting to the Provider..."
import-module $modulePath -force
if ((get-psdrive $siteCode -erroraction SilentlyContinue | measure).Count -ne 1) {
new-psdrive -Name $siteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer
}
cd $siteDrive

"Gathering DP Group Names..."
$intcounter = 1
#Create a hashtable
$DPgroups = @{0 = "Name"}
$DPgroups.Remove(0)
Get-CMDistributionPointGroup | select Name | sort Name | % {
$DPgroups += @{$intcounter = $_.Name}
$intcounter++
}

#Choose the DP group
$dpgroups.GetEnumerator() | Sort-Object name
$DPgroup = read-host "Select a DP group, by number and press [enter]"
$DPGroupName = $DPgroups.get_item([int]$DPgroup)

switch ($objectTypeID)
{
#ObjectTypeIDs from SMS_ObjectContentInfo WMI Class
2 {Start-CMContentDistribution -PackageID $PackageID -DistributionPointGroupName $DPGroupName}
14 {Start-CMContentDistribution -OperatingSystemInstallerID $PackageID -DistributionPointGroupName $DPGroupName}
18 {Start-CMContentDistribution -OperatingSystemImageID $PackageID -DistributionPointGroupName $DPGroupName}
19 {Start-CMContentDistribution -BootImageID $PackageID -DistributionPointGroupName $DPGroupName}
21 {"SMS_DeviceSettingPackage - Nothing to distribute here"}
23 {Start-CMContentDistribution -DriverPackageID $PackageID -DistributionPointGroupName $DPGroupName}
24 {Start-CMContentDistribution -DeploymentPackageID $PackageID -DistributionPointGroupName $DPGroupName}
31 {Start-CMContentDistribution -ApplicationName $SoftwareName -DistributionPointGroupName $DPGroupName}
}

"DP Group Targeted distributed-Use the Monitoring node to monitor DP status."

Write-Host "Complete. Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Now re-launch your ConfigMgr Admin console to use the new r-click->Send to DP Group feature. As you can see from the code, we use Get-CMDistributionPointGroup to obtain all DP groups, and then create a hash table to allow us to display a simple selector. We then use Start-CMContentDistribution to send the content to the desired DP Group. Notice the required argument is based on the object type (package, application, updates deployment package, etc.), so we use a simple switch statement to determine the appropriate parameters to run.

Happy Scripting!

Greg
ramseyg@hotmail.com

How To: Promote an Application Simulation to a Required Deployment in ConfigMgr 2012 SP1

A simulated deployment is a great way to validate detection rules and deployment types prior to deploying an application. In my opinion, there’s one small task that’s missing - the ability to promote a simulation to production.

This post will demonstrate how to create a right-click action on the Monitoring->Deployments tab to promote a simulation to a required deployment.

promotesimulation

Selecting the action “Promote Simulation to Production” will launch PowerShell and display the simulation information (numbertargeted, numbersuccess, numbererrors, etc):

promotesimulation-2

You can also see that by default, the script is configured to create a deadline for 8:00 PM of the date in which the script is run. Be sure to modify the script to fit your needs (as well as avoid surprises).

You can download the .zip file and follow the directions in the included ‘info.txt’ file for a fast deployment to your admin console. You can view additional details below.

First you must create the proper r-click context menu. Copy the following .xml, save it as “PromoteSIMToProd.xml”, and copy it to C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\d1621955-48ad-4bba-9c85-95f74c0c6538\PromoteSIMtoProd.xml. (Adjust the path as appropriate to your ConfigMgr Admin Console installation path).

<ActionDescription DisplayName="Promote Simulation to Production" MnemonicDisplayName="Promote Simulation to Production" Description = "Removes Simulation and Creates Mandatory Deployment based on Simulation Config" RibbonDisplayType="TextAndSmallImage">
<ShowOn>
<string>ContextMenu</string>
<string>DefaultHomeTab</string>
</ShowOn>
<Executable>
<FilePath>PowerShell.exe</FilePath>
-ExecutionPolicy RemoteSigned -File C:\PowerShell\CM12RClickTools\PromoteSIMToProd.ps1 "##SUB:DeploymentID##" "##SUB:__Server##" "##SUB:__Namespace##" "##SUB:CollectionID##"
</Executable>
</ActionDescription>

Notice in the .xml that we specify the -ExeuctionPolicy RemoteSigned parameter. Best practice would be to sign your scripts, but if that’s not something you can manage easily, you can use the parameter as shown to modify the execution policy for the specific instance you’re launching, instead of changing the execution policy for all script execution. Next, copy the PowerShell code below, and save it to C:\PowerShell\CM12RClickTools\PromoteSIMToProd.ps1

#capturing arguments:
$DeploymentID = $args[0]
$SiteServer = $args[1]
$SiteNamespace = $args[2]
$SiteCode = ($args[2]).Substring(14)
$CollectionID = $args[3]
$SiteDrive = $sitecode + ":"

#"{0}, {1}, {2}, {3}, {4}, {5}" -f $DeploymentID, $SiteServer, $SiteNamespace, $CollectionID, $Sitecode, $siteDrive

#setting a hard avail time and deadline of 20:00 on the same day the script is run.
##$availDate = read-host "Enter deadline date (e.g., 12/02/1973)"
#$availableTime = read-host "Enter deadline Time (e.g., 18:00 for 6:00pm)"
$availDate = (get-date).toshortdatestring()
$availtime = "20:00"  # if you want to configure for current time, (use get-date -format H:mm)
$deadlineDate = (get-date).toshortdatestring() #to specify a time in the future, just enter a date string like "12/02/2023" (with quotes)
$deadlineTime = "20:00"

"Querying Simulation Information..."
#Connect to PowerShell Provider:
$ModulePath = $Env:SMS_ADMIN_UI_PATH.Replace(„\bin\i386“,“\bin\ConfigurationManager.psd1“)

import-module $modulePath -force
if ((get-psdrive $siteCode -erroraction SilentlyContinue | measure).Count -ne 1) {
new-psdrive -Name $siteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer
}
cd $siteDrive

#"{0},{1}" -f $Coll.name.tostring(), $Coll.membercount.Tostring()

"Get Simulation Deployment Info"
$simDeploy = get-cmdeployment -deploymentid $DeploymentID
if ($simDeploy.DeploymentIntent -ne 3) {
"`nOnly Simulations can be Promoted to active deployments!`n"
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
break
}
$simDeploy

#Get Collection info, so we can show potential number of systems impacted
#    (for some reason, get-cmdevicecollection wasn't dispalying membercount consistently through script)
$Filter = "CollectionID='$CollectionID'"
$Coll = gwmi sms_collection -Namespace $SiteNamespace -ComputerName $SiteServer -filter $filter

#Display info to admin before proceeding.
"`nAvailable: {0}, {1}" -f $availdate, $availtime
"Deadline: {0}, {1}" -f $deadlineDate, $deadlineTime
"Collection: {0}" -f $Coll.Name
"Total Collection members: {0}" -f $Coll.membercount

#Prompt user to verify available and deadline times, and to confirm required deployment
$x = read-host ("Press [CTRL+C] to exit, or Press any key to create the required deployment ...")

"Promoting Simulation to Production..."

"Removing Simulation..."
remove-cmdeployment -ApplicationName $SimDeploy.SoftwareName -DeploymentID $simDeploy.DeploymentID -force
"Creating new Application Deployment"
Start-CMApplicationDeployment -CollectionName $simDeploy.CollectionName -Name $SimDeploy.SoftwareName  -AvaliableDate $availDate -AvaliableTime $availTime -Comment "Simulation Promoted to Production by $env:Username" -DeadlineDate $deadlineDate -DeadlineTime $deadlineTime -DeployAction Install -DeployPurpose Required -EnableMomAlert $True -PreDeploy $True -RaiseMomAlertsOnFailure $True -UserNotification DisplaySoftwareCenterOnly

Write-Host "Complete. Press any key to continue ..."

$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Now re-launch your ConfigMgr Admin console to use the new r-click->Promote Simulation to Production feature. As you can see from the code, we use Get-CMDeployment to obtain the details of the simulation – and we verify it’s a simulation by DeploymentIntent=3. We then perform a WMI query to get information on the targeted collection, so that we can show the admin the total collection member count. After prompting the admin to continue, we simply call Remove-CMDeployment to remove the simulation, and then use the information previously queried and call Start-CMApplicationDeployment to deploy the application. Include additional parameters for Start-CMApplicationDeployment to standardize the deployments for your environment. For example, you could add -RaiseMomAlertsOnFailure $True -OverrideServiceWindow $True to the command line.

So as you can see, this could be a huge opportunity to ensure a consistent, automated process for application deployment.

Happy Scripting!

Greg
ramseyg@hotmail.com

How to: Add a “Delete Deployment” Action to Right-Click Actions in ConfigMgr 2012

Many times I find myself looking at Monitoring->Deployments in the ConfigMgr 2012 admin console, and find deployments that should be removed. The “out of the box” process to remove deployments is to browse to the object being deployed (Package, Application, Setting, TS, etc.), select the deployment, and then delete. This process requires a few more clicks than I would like to do, so I created a right-click tool that will allow you to delete the deployment from the Monitoring tab.

Download R-Click_DeleteDeployment.zip

deletedeployment
You can download the .zip file and follow the directions in the included ‘info.txt’ file for a fast deployment to your admin console. You can view additional details below.

First you must create the proper r-click context menus. Copy the following .xml, save it as “DeleteDeployment.xml”, and copy it to the following locations (create subfolders as necessary):

  • C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\e6a632fa-a43f-432f-b081-8fb0b7065f37\DeleteDeployment.xml
  • C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\d1621955-48ad-4bba-9c85-95f74c0c6538\DeleteDeployment.xml
  • C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\93218e21-485a-4e2b-9f23-77c76145e214\DeleteDeployment.xml

(Adjust the path as appropriate to your ConfigMgr Admin Console installation path).

<ActionDescription DisplayName="Delete Deployment" MnemonicDisplayName="Delete Deployment" Description = "Deletes Deployment" RibbonDisplayType="TextAndSmallImage"></pre>
<ShowOn>
 <string>ContextMenu</string>
 <string>DefaultHomeTab</string>
 </ShowOn>
 <Executable>
 <FilePath>PowerShell.exe</FilePath>
 <Parameters>-ExecutionPolicy RemoteSigned -File C:\PowerShell\CM12RClickTools\DeleteDeployment.ps1 "##SUB:DeploymentID##" "##SUB:__Server##" "##SUB:__Namespace##" "##SUB:CollectionID##" </Parameters>
 </Executable>
 </ActionDescription>

Notice in the .xml that we specify the -ExeuctionPolicy RemoteSigned parameter. Best practice would be to sign your scripts, but if that’s not something you can manage easily, you can use the parameter as shown to modify the execution policy for the specific instance you’re launching, instead of changing the execution policy for all script execution. Next, copy the PowerShell code below, and save it to C:\PowerShell\CM12RClickTools\DeleteDeployment.ps1


#use this script to delete Deployments from the monitoring node.
#capturing arguments:
$DeploymentID = $args[0]
$SiteServer = $args[1]
$SiteNamespace = $args[2]
$SiteCode = ($args[2]).Substring(14)
$CollectionID = $args[3]
$SiteDrive = $sitecode + ":"
"Deleting Deployment..."

#Connect to PowerShell Provider:
$ModulePath = (($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + '\ConfigurationManager.psd1'

import-module $modulePath -force
if ((get-psdrive $siteCode -erroraction SilentlyContinue | measure).Count -ne 1) {
new-psdrive -Name $siteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer
}
cd $siteDrive

"Get Deployment Info..."
$Deploy = get-cmdeployment -deploymentid $DeploymentID
$Deploy

"Removing Deployment..."
Switch ($deploy.FeatureType) {
1 {
#Application
remove-cmdeployment -ApplicationName $Deploy.SoftwareName -DeploymentID $Deploy.DeploymentID -force
}
2 {
#Package/Program
#Set Filter
$advertFilter = "AdvertisementID='$DeploymentID'"
#query WMI and Delete
gwmi sms_advertisement -Namespace $SiteNamespace -ComputerName $SiteServer -filter $advertFilter | % {$_.Delete()}
}
5 {
#software update
#Set Filter
$advertFilter = "AssignmentUniqueID='$DeploymentID'"
#query WMI and Delete
gwmi SMS_UpdatesAssignment -Namespace $SiteNamespace -ComputerName $SiteServer -filter $advertFilter | % {$_.Delete()}
}

6 {
#baseline
#Set Filter
$advertFilter = "AssignmentUniqueID='$DeploymentID'"
#query WMI and Delete
gwmi sms_baselineassignment -Namespace $SiteNamespace -ComputerName $SiteServer -filter $advertFilter | % {$_.Delete()}
}
7 {
#Task Sequence
#Set Filter
$advertFilter = "AdvertisementID='$DeploymentID'"
#query WMI and Delete
gwmi sms_advertisement -Namespace $SiteNamespace -ComputerName $SiteServer -filter $advertFilter | % {$_.Delete()}
}

Default {
#display feature type
write-host ("No defined method to delete " + $deploy.FeatureType)
}

}

Write-Host "Complete. Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Now re-launch your ConfigMgr Admin console to use the new r-click->Delete Deployment feature. As you can see from the code, we have to take different actions based on the object type to delete. Remove-CMDeployment only removes Application deployments, while Get-CMDeployment returns all deployments.
We use Get-CMDeployment to obtain vital information for each deployment, and then based on featuretype, perform the appropriate Delete method.

Happy Scripting!

Greg
ramseyg@hotmail.com

How To: List Packages that are Configured to use a Package Share in ConfigMgr 2012

Here’s a sample script to display all packages that have the option enabled to “Copy the content in this package to a package share on distribution points.”

get-cmpackage | foreach {
  if ($_.pkgflags -eq ($_.pkgflags -bor 0x80)) {
  "pkg share bit enabled on {0}" -f $_.Packageid
  }
}

To run the script, launch PowerShell from your ConfigMgr Admin Console, or import the ConfigMgr module, and paste it into the command screen or run it as a .ps1 file.  As you can see, we run get-cmpackage to query for all packages on the ConfigMgr site. You will noticed that get-cmpackage may take some time to run in an environment with a large number of packages, because it is also querying the lazy properties for each package. Next we run a for-each loop to check the package flags. We then use the bitwise operator -bor to compare the current pkgflags value to see if the value 0×80 has already been applied, and display a message if it finds the checkbox enabled.

You can find more information about pkgflags on msdn.

For reference, here’s the setting on the package:
pkgshareproperty

Happy Scripting,

 

Greg

 

Upgrading to ConfigMgr 2012 SP1, and using Applications?

Check out my MVP colleague Kenny’s blog to learn what you need to do to get applications healthy.

How to: Integrate Dell iDRAC into ConfigMgr 2012

This post describes how to capture the Dell iDRAC IP address with ConfigMgr hardware inventory, and create a right-click extension to allow you to launch the iDRAC from the ConfigMgr admin console. If your Dell PowerEdge servers include the Dell Lifcecycle Controller, carefully review the Dell Lifecycle Controller Integration for System Center Configuration Manager to determine if that integration pack fits your needs.

What is an iDRAC?

The Integrated Dell Remote Access Controller (iDRAC) is designed to make server administrators more productive and improve the overall availability of Dell servers. iDRAC alerts administrators to server issues, helps them perform remote server management, and reduces the need for physical access to the server.

Prerequisites

In order to properly capture DRAC information, the following configuration is required:

  • Dell PowerEdge Server – The target server must be a Dell PowerEdge Server licensed to use the virtual console, running a supported version of Microsoft Windows Server.
  • Dell OpenManage Server Administrator (OMSA) must be installed on each server – the OMSA client must be installed on the server, as it is used to populate the OMSA information into WMI.
  • System Center 2012 Configuration Manager (ConfigMgr), although similar methods to capture the iDRAC IP address can be used by other enterprise systems management tools.

Configuring Hardware Inventory to Capture the iDRAC IP Address

ConfigMgr uses hardware inventory to capture information from the Windows registry as well as from Windows Management Instrumentation (WMI). OMSA populates the iDRAC IP information into WMI. This example modifies the hardware inventory configuration for the Default Client Settings. Review additional steps for extending hardware inventory on Microsoft TechNet.

To enable hardware inventory to capture Dell iDRAC IP information:

  1. From the Primary or Central site, launch the ConfigMgr console, and navigate to Administration->Client Settings.
  2. Select Default Client Settings and choose Properties from the ribbon.
  3. In the Default Settings dialog, select Hardware Inventory, and then choose the Set Classes button.
  4. Choose Add from the Hardware Inventory Classes dialog.
  5. From the Add Hardware Inventory Class dialog, choose the Connect button, and enter the computer name of a server that has Dell OMSA installed, and enter root\cimv2\dell for the namespace. Enable the Recursive checkbox and click OK.
  6. Type RemoteAccess into the search bar, and then enable the checkbox for the Dell_RemoteAccessServicePort, and then click OK. Click OK again to save changes to the Hardware Inventory Classes configuration and finally click OK again on the Default Settings Dialog to save all changes from the previous child dialogs.

remoteAccess

You have successfully enabled hardware inventory on the Dell_RemoteAccessServicePort class to capture the iDRAC IP. Servers with OMSA installed will begin sending information for this new hardware information back via hardware inventory on the defined inventory interval (by default, 7 days). You can expedite this process from the ConfigMgr control panel applet by refreshing Machine Policy action, followed by initiating a hardware inventory. This process will run for approximately five minutes. You can confirm the information has been successfully inventoried by viewing Resource Explorer.

Extending the ConfigMgr Console to launch iDRAC

Now that you have the data in ConfigMgr, follow these steps to launch the iDRAC for a device in the ConfigMgr admin console.

  1. Close any existing instances of the ConfigMgr Console.
  2. Download LaunchDelliDrac.zip Extract DellLaunchiDrac.ps1 and copy to C:\PowerShell\CM12RClickTools\DellLaunchiDRAC.PS1.
  3. Extract Dell.xml from the .zip previously downloaded and coy 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). Depending on your admin console installation, the path may need to be modified.
  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 choose the option to launch the iDRAC under the new custom menu, as shown here:

LaunchIDRAC

Congrats! You now have a right-click tool to easily launch the iDRAC! You can find more information about adding additional extensions (aka right-click tools) on TechNet.

Greg

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 File for Dell.XML (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>
</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

Follow

Get every new post delivered to your Inbox.

Join 1,045 other followers