1 / 27

Managing System Center 2012 Configuration Manager with Windows PowerShell

MEMUG August 23 rd 2013. Managing System Center 2012 Configuration Manager with Windows PowerShell. Overview. Previously ConfigMgr could only be managed via WMI or the SDK Using Windows PowerShell required WMI. Requirements.

hisa
Download Presentation

Managing System Center 2012 Configuration Manager with Windows PowerShell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MEMUG August 23rd 2013 Managing System Center 2012 Configuration Manager with Windows PowerShell

  2. Overview • Previously ConfigMgr could only be managed via WMI or the SDK • Using Windows PowerShell required WMI

  3. Requirements • Service Pack 1 for System Center 2012 adds native Windows PowerShell support for Configuration Manager • Windows PowerShell 3.0 is required • $Host.version will display the current version • Windows 8 & Server 2012 include Windows PowerShell 3.0 by default • Windows 7 & Server 2008 R2 include Windows PowerShell 2.0, which is not compatible. You can upgrade to version 3.0 by installing "Windows Management Framework 3.0"http://www.microsoft.com/en-us/download/details.aspx?id=34595

  4. PowerShell 2.0 not supported

  5. PowerShell 32-bit Required • On a 64-bit OS, there are two versions of Windows PowerShell - 64-bit and 32-bit versions • The ConfigurationManager module must run in the 32-bit version of PowerShell, but if you are downloading for a 64-bit OS you must download & install the 64-bit version which includes a 32-bit version

  6. PowerShell 64-bit Not Supported

  7. Remote Management • If the site server is not running Windows Server 2012, managing the site from a remote workstation is recommended rather than upgrading PowerShell • Installing PowerShell 3.0 on a Windows Server 2008 R2 site server is not recommended • Using Windows 8 is recommended, since the Integrated Scripting Environment (ISE) is more advanced than the Windows 7 version

  8. PowerShell Crash Course • Windows PowerShell has two components: • Interactive command shell (similar to cmd.exe or Unix Bourne/Korn shells) • A scripting engine / scripting language • Native commands are called Cmdlets (command-lets) • All Cmdlets should use the Verb-Noun naming convention, separated by a hyphen (i.e. Get-Help, Start-Process) • The script language version was meant to be separate from the shell version, so .PS1 files are used with PowerShell 1.0, 2.0, 3.0

  9. Get-Help • Get-Help *process* • Get-Help Get-Process (same as Get-Process -?) • Only helpful to jog your memory, not to learn • Get-Help Get-Process-Examples • Get-Help Get-Process-Detailed • Get-Help Get-Process -Full • Get-Help Get-Process -Online • Get-Help about_CommonParameters • Get-Help about*

  10. Get-Command • Get-Command lists all available commands (similar to where.exe) • Includes all Cmdlets, Functions, Aliases and executables in the %PATH% (i.e. net.exe) • Get-Command net* • Get-Command *dir* • Get-Command -CommandType Cmdlet • Get-Command Dir -CommandType Alias • dir -> Get-ChildItem

  11. Command Pipelines • Sending the output of one command to another command • Get-Process notepad | Stop-Process • Get-Process | Select-Object "ProcessName" > OutputFile.txt • Get-Help about_pipelines

  12. Get-Member • Everything in PowerShell is an object, even strings. Get-Member exposes the details of an object (Properties, Methods, etc.) • Most examples show the | pipe option: • $x = "this is a string" • $x | Get-Member • Avoid that, it's confusing with arrays, hashtables & collections: • $x = @("This is string1","This is string2") • $x | Get-Member • TypeName: System.String • Use -InputObject instead: • Get-Member -InputObject $x • TypeName: System.Object[]

  13. Get-PSDrive

  14. ConfigMgr Module Basics • Opening PowerShell will not automatically load the ConfigMgr module (unless you add it to your $Profile) • Get-Module -ListAvailable will not show it as available even if it is installed. • Options: • Run it from the top-left menu of the ConfigMgr console • Load the module manually

  15. Connect via Windows PowerShell

  16. Connect via Windows PowerShell

  17. ConfigMgr Module Basics (Cont.) • Load the module manually (assuming D: and sitecode XYZ): • cd "D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin" • Import-Module ".\ConfigurationManager.psd1" • cd XYZ: • Verbose option: • Import-Module "D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" -Verbose • Get-PSDrive • Set-Location XYZ: (site code) • Get-Alias cd • cd -> Set-Location

  18. Get-Help (Cont.) • Get-Help Get-CMSite (same as Get-CMSite -?) • Get-Help Get-CMSite -Full • Get-Help Get-CMSite -Online

  19. Get-Command (Cont.) • Get-Command -Module ConfigurationManager • Get-Command -Module ConfigurationManager *site* • Get-Command -Module ConfigurationManager *server* • Get-Command -Module ConfigurationManager *package* • Get-Command -Module ConfigurationManager *role* • Get-Command -Module ConfigurationManager *boundary*

  20. Demo - Boundary Groups • Get-Command -Module ConfigurationManager *boundary* • Get-Help New-CMBoundary -Full • Get-Help New-CMBoundaryGroup -Full • $ADSiteName = "Default-First-Site-Name" • $BoundaryName1 = "Test Boundary ADSite 1" • New-CMBoundary -Name $BoundaryName1 -Type ADSite -Value $ADSiteName • $BoundaryName2 = "Test Boundary IPRange 1" • $IPRange = "10.0.0.1-10.255.255.254" • New-CMBoundary -Name $BoundaryName2 -Type IPRange -Value $IPRange • $BoundaryGroupName = "Test BoundaryGroup 1" • New-CMBoundaryGroup -Name $BoundaryGroupName -DefaultSiteCode (Get-CMSite).SiteCode -Description "PowerShell Test" • Add-CMBoundaryToGroup -BoundaryGroupName $BoundaryGroupName -BoundaryName $BoundaryName1 • Add-CMBoundaryToGroup -BoundaryGroupName $BoundaryGroupName -BoundaryName $BoundaryName2 • Remove-CMBoundary -Name $BoundaryName1 -Force • Remove-CMBoundary -Name $BoundaryName2 -Force • Remove-CMBoundaryGroup -Name $BoundaryGroupName -Force

  21. Demo - Collections • New-CMDeviceCollection -Name "Windows 7" -LimitingCollectionName "All Systems" • Add-CMDeviceCollectionQueryMembershipRule -RuleName "Windows 7" -CollectionName "Windows 7" -QueryExpression "SELECT SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client FROM SMS_R_System WHERE OperatingSystemNameAndVersion LIKE '%Workstation 6.1%'" • New-CMDeviceCollection -Name "Windows XP" -LimitingCollectionName "All Systems" • Add-CMDeviceCollectionQueryMembershipRule -RuleName "Windows XP" -CollectionName "Windows XP" -QueryExpression "SELECT SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client FROM SMS_R_System WHERE OperatingSystemNameAndVersion LIKE '%Workstation 5.1%'" • Remove-CMDeviceCollection -Name "Windows 7" -Force • Remove-CMDeviceCollection -Name "Windows XP" -Force

  22. Demo - Distribution Point Groups • $DistributionPointName = "sccm01.demo.local" • $DistributionPointGroupName = "Test Distribution Point Group 1" • New-CMDistributionPointGroup -Name $DistributionPointGroupName • Add-CMDistributionPointToGroup -DistributionPointName $DistributionPointName -DistributionPointGroupName $DistributionPointGroupName • Remove-CMDistributionPointGroup -Name $DistributionPointGroupName -Force

  23. Demo - Distribution Points • # Example 1: Distribute a boot image • Start-CMContentDistribution -BootImageId "CM200004" -CollectionName "All Systems" -DistributionPointName "CMDIV-WEST04.CORP.CONTOSO.COM" -DistributionPointGroupName "DistPtGroup02" • # Example 2: Distribute a task sequence • Start-CMContentDistribution -TaskSequenceId "CM200007" -CollectionName "All Systems" -DistributionPointName "CMDIV-WEST04.CORP.CONTOSO.COM" • # Example 3: Distribute an application • Start-CMContentDistribution -ApplicationName "Dict.app" -CollectionName "All Systems" -DistributionPointName "CMDIV-WEST04.CORP.CONTOSO.COM" -DistributionPointGroupName "DistPtGroup02" • # Example 4: Distribute a package • Start-CMContentDistribution -PackageId "CM200001" -CollectionName "All Systems" -DistributionPointName "CMDIV-WEST04.CORP.CONTOSO.COM" -DistributionPointGroupName "DistPtGroup02" • # Example 5: Distribute a deployment package • Start-CMContentDistribution -DeploymentPackageName "DivDeployPkg01" -CollectionName "All Systems" -DistributionPointName "CMDIV-WEST04.CORP.CONTOSO.COM" -DistributionPointGroupName "DistPtGroup02" • # Example 6: Distribute a driver package • Start-CMContentDistribution -DriverPackageName "DrvPkg02" -CollectionName "All Systems" -DistributionPointName "CMDIV-WEST04.CORP.CONTOSO.COM" -DistributionPointGroupName "DistPtGroup02" • # Example 7: Distribute an operating system image • Start-CMContentDistribution -OperatingSystemImageId "CM200013" -CollectionName "All Systems" -DistributionPointName CMDIV-WEST04.CORP.CONTOSO.COM -DistributionPointGroupName "DistPtGroup02" • # Example 8: Distribute an operating system installer • Start-CMContentDistribution -OperatingSystemInstallerId "CM200017" -CollectionName "All Systems" -DistributionPointName CMDIV-WEST04.CORP.CONTOSO.COM -DistributionPointGroupName "DistPtGroup02"

  24. Demo - Forest Discovery • Get-Command -Module ConfigurationManager *Forest* • (Get-CMActiveDirectoryForest).EnableDiscovery • New-CMActiveDirectoryForest -ForestFqdn (Get-WmiObject Win32_ComputerSystem).Domain -EnableDiscovery $True • Set-CMActiveDirectoryForest -ForestFqdn (Get-WmiObject Win32_ComputerSystem).Domain-EnableDiscovery $False • (Get-CMActiveDirectoryForest).EnableDiscovery

  25. Demo - AD Discovery • Get-CMDiscoveryMethod # Heartbeat Discovery is missing • Set-CMDiscoveryMethod -ActiveDirectorySystemDiscovery -Enabled $true • Set-CMDiscoveryMethod -ActiveDirectoryUserDiscovery -Enabled $true • Set-CMDiscoveryMethod -ActiveDirectoryGroupDiscovery -Enabled $true • Set-CMDiscoveryMethod -ActiveDirectoryForestDiscovery -Enabled $true

  26. Demo - Roles • New-CMAdministrativeUser -RoleName "Full Administrator" -Name "DEMO\Domain Admins" • # This doesn't seem to work: • Remove-CMAdministrativeUser -RoleName "Full Administrator" -Name "DEMO\Domain Admins" -Force

  27. Demo - Deployments • Clear-CMPxeDeployment -DeviceCollectionId "12A00001" -Force • Enable-CMSoftwareUpdateAutoDeploymentRule -Name "Software Updates - Workstations - Baseline" • Start-CMApplicationDeployment -CollectionName "All Users" -Name "7-Zip" -AvailableDate 2013/08/23 -AvailableTime 11:00 -Comment "Test 1" -DeadlineDate 2013/08/30 -DeadlineTime 23:59 -DeployAction Install -OverrideServiceWindow $False -RebootOutsideServiceWindow $False -UseMeteredNetwork $False -UserNotification DisplayAll • Start-CMPackageDeployment -CollectionName "Windows XP Clients" -PackageName "7-Zip 9.20" -DeviceProgramName "7-Zip 9.20 Silent Install" -Comment "Test created by PowerShell" -DeploymentStartDay 2013/08/23 -DeploymentStartTime 11:00

More Related