Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

some sccm 2012 scripts n' tools

Publié le par damcuvelier


- SCCM 2012 R2 PowerShell module Import\Export Collections: https://gallery.technet.microsoft.com/scriptcenter/SCCM-2012-R2-PowerShell-308b0f27

- Setting Maintenance Windows in SCCM 2012 R2 With Powershell: Setting Maintenance Windows in SCCM 2012 R2 With Powershell

- PowerShell and Configuration Manager 2012 R2: https://blogs.technet.microsoft.com/heyscriptingguy/2015/11/16/powershell-and-configuration-manager-2012-r2part-1/

- Cmdlet Reference. System Center 2012 R2: https://technet.microsoft.com/en-us/library/jj821831(v=sc.20).aspx

- Powershell script to create Deployment of Package/Application/TS in SCCM2012: https://gallery.technet.microsoft.com/Powershell-script-to-a8e99319

- Connecting to Configuration Manager with Windows PowerShell: Connecting to Configuration Manager with Windows PowerShell

- Getting Started with Configuration Manager and Windows PowerShell: https://msdn.microsoft.com/en-us/library/dn528997.aspx

- Install Azure PowerShell Module In Windows 10: https://prajwaldesai.com/install-azure-powershell-module-in-windows-10/

- SCCM WINDOWS 10 CUSTOMIZATION USING TASK SEQUENCES: https://www.systemcenterdudes.com/sccm-windows-10-customization/

--------------------------------------------

To load the module, you need to run this code in Windows PowerShell:
Import-Module ‘C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1’
You can now access the list of the available cmdlets by using the Get-Command cmdlet and targeting the new module:
Get-Command –module ConfigurationManager

Before you get too far, remember you’re going to need to bring in Help for this new module. Remember the Help is no longer built-in by default. I had initially forgotten this, and I was uttering “magic phrases” when I could not find any examples to work with.
….and then a few moments later, I smacked the front of my head realizing what I needed to do:
Update-Help –module ConfigurationManager

Moments later, Help was on its way!
Your next challenge seems trivial, but you might try to run something simple like getting a list of boundaries with the Get-CMBoundarycmdlet. You'll run in to this little error message:
Get-CMBoundary: This command cannot be run from the current drive. 

To run this command, you must first connect to a Configuration Manager drive.
Well, isn’t that a special little message? In reality, you must be in the context of your Configuration Manager site. This is simply an extension of the PSDrives in your Windows PowerShell console, and it is very much the same as changing a drive letter.
The actual “letter” (if you want to think of it like that) is simply your site code. Now I could tell you, “Just go look that up in the GUI.” I could do that.
But this is a Hey, Scripting Guys! Blog post, and it would make far more sense to show you how to get that information with Windows PowerShell, right?

To programmatically access the site name, you should use an object like this in a PowerShell script that uses the cmdlets—or perhaps add this to your profile if you regularly work with the Configuration Manager cmdlets:
$CMSite=”$(Get-PSDrive –PSProvider CMSite)`:”
Set-Location $CMSite

When you run this, you’ll see a prompt similar to this on your console :
From this point we can directly ask Configuration Manager questions, such as, "What are the boundaries on this site?"
Get-CMBoundary

Or maybe something interesting like finding out the Configuration Manager site system server:
Get-CMSiteSystemServer

And of course, all of this information is easily exportable by using Export-CSV or Export-CLIXML. 
There are some amazing solutions on the Internet for documenting a Configuration Manager environment by using Windows PowerShell!

----------------------------------------

Load the Configuration Manager cmdlets and work with collections:

Get-Command –module ConfigurationManager Get*Collection*
Get-CMDeviceCollection | Format-Table
Get-CMDeviceCollection | Select-Object CollectionID, Comment, LocalMemberCount, LastRefreshTime
Get-CMDeviceCollectionDirectMembershipRule –CollectionName ‘<your collection name>’
Get-CMDeviceCollectionQuery –CollectionName <your collection name>’
New-CMDeviceCollection –Name ‘<the new collection ame>’ –LimitingCollectionName ‘All Systems’
Remove-CMDeviceCollection –Name ‘<the name of the collection to remove>’ –confirm:$False -force


and so much in https://blogs.technet.microsoft.com/heyscriptingguy/2015/11/18/powershell-and-configuration-manager-2012-r2part-3/

 

enjoy!

Commenter cet article