PowerShell: Disable Automatic Loading of Modules in PowerShell 3.0

  One of the new features in PowerShell 3.0 is the Auto Loading of Modules. This feature is great for discovering commands, but can be really annoing when trying to test if your script works as it is supposed to. Luckily we can change the settings using an automatic variable. $PSModuleAutoloadingPreference Here is the info from the help: $PSModuleAutoloadingPreference------------------------------      Enables and disables automatic importing of modules in the session.       "All" is the default. Regardless of the value of this variable, you      can use the Import-Module cmdlet to import a module.      Valid values are:        All    Modules are imported automatically on [...]

Take control of your ConfigMgr Collections part 1

If you are managing a large ConfigMgr environment, then it is important to know when your collections updating their memberships and if your collections are updating exactly the same time, then it may hit your SQL very badly. This script reads all the collections and you can specify which output you want – CSV or HTML. You can download the script from here

System Center 2012 Configuration Manager SP1 Cumulative Update 1 PowerShell Parameter Sets Excel Sheet

I just updated the SP1 RTM version of Configuration Manager 2012 SP1 RTM PowerShell Parameter Sets Excel sheet and with SP1 CU1 we have 511 CMDLETS and 1675 parametersets :)   You can download the Excel Sheet from here Happy Scripting Kaido    

PowerShell – How to do WMIClass CreateInstance but WITH credentials

Today I was building a script to create system resources in SCCM 2012 and part of the task was to add these resources to a set of collections. The script will use from the SCCM server when finally implemented but for now I was using my laptop for editing and debugging. When I came to the point where I had to create the actual membership rules for the collections I ran into a hurdle that puzzled me. The WMI object I had to create was the SMS_CollectionRuleDirect, which often is done using this simple PowerShell snippet: $ruleClass = [WMICLASS]"\\$($server)\root\sms\site_$($sitecode):SMS_CollectionRuleDirect".CreateInstance() And [...]

PowerShell to the rescue – Clean up direct collection memberships

We where talking to a customer about how to avoid waiting for Active Directory group synchronization to occur and place a device in the correct collections faster than “until the next synchronization”. The main problem with this setup was caused by the fact that they used a group-in-group membership to identify collection memberships and apparently SCCM 2012 don’t include indirect changes to group membership as delta changes (I have not tested this in details yet). So we came up with the idea to just create a direct membership to place the device in the collections instantly to make sure that [...]

By | 2013-03-12T12:31:15+00:00 March 12th, 2013|Configuration Manager (SCCM), Powershell|3 Comments

How can I determine what Antimalware Policy is applied to my SCEP 2012 SP1 client

Niall Brady posted a blog post a few days ago How can I determine what Antimalware Policy is applied to my SCEP 2012 SP1 client. Niall showed how to check Antimalware Policy via registry or via Configuration Manager Console. Actually there is one method more - Antimalware policy is also stored in WMI class . You can use query below to identify the Antimalware policy from WMI. $EmptyPolicy= @() $EPPolicy = Get-wmiObject -namespace "Root\ccm\Policy\Machine\ActualConfig" -query "Select Name from CCM_AntiMalwarePolicyClientConfig" | ForEach-Object {$EmptyPolicy+=$_.Name} $EmptyPolicy | Group-Object | Select-Object -Property Name -Unique   Script Output  

By | 2013-02-22T18:53:09+00:00 February 22nd, 2013|Configuration Manager (SCCM), Powershell|1 Comment

CSV REPORT: Get ConfigMgr Collection Excluded or Included Collection Rules

Currently there should be no builtin report that will show you Excluded or Included collections and because of that I did two simple PowerShell scripts that queries Included or Excluded collections. Both of these scripts creates a CSV file. You can run this script on your Primary, CAS or Central site like this: Get-CMCollectionExcludedCollectionRules.ps1 -SiteCode PS1 -SiteServer Localhost -OutPut c:\Temp\ExcludedCollectionReports.csv Get-CMCollectionIncludedCollectionRules -SiteCode PS1 -SiteServer Localhost -OutPut c:\Temp\IncludedCollectionReports.csv Get-CMCollectionIncludedCollectionRules.ps1 Get-CMCollectionExcludedCollectionRules.ps1 Example Output  

By | 2013-01-31T14:47:18+00:00 January 31st, 2013|Configuration Manager (SCCM), Powershell|1 Comment

Quick and Dirty Management Point check

If you have a big Configuration Manager environment and you don´t have a monitoring solution like SCOM or NAGIOS, then PowerShell can help you too.  This script queries all Management Points from SMS_SystemResourceList WMI class and it will check MPCERT and MPLIST website status. If you want to use this script then run it on your Central, CAS or Primary Site Server like this: Get-CMSMPStatus.ps1 -SiteCode PS1 -SiteServer Localhost -OutPut c:\Temp\MPStatus.csv. This will create a CSV Report (example below) This script should work with PSH v2 and v3. You can download the code example from here

By | 2013-01-29T14:20:44+00:00 January 29th, 2013|Configuration Manager (SCCM), Powershell|1 Comment

Powershell to change Resolution State in Operations Manager 2012

A powershell sample used at a customer for semi-automatically changing the Resolution States: [crayon-59c13692455a2899295421/] [crayon-59c13692455ab661027863/] [crayon-59c13692455ae554827796/] [crayon-59c13692455b1396690947/] [crayon-59c13692455b4403496366/] [crayon-59c13692455b7883233270/] [crayon-59c13692455b9793033306/] [crayon-59c13692455bc886233784/] [crayon-59c13692455bf182612429/] [crayon-59c13692455c1982857145/] [crayon-59c13692455c4377909619/] [crayon-59c13692455c7748164141/] [crayon-59c13692455c9825803771/] [crayon-59c13692455cc227220359/] [crayon-59c13692455cf253048241/] [crayon-59c13692455d1002498424/] [crayon-59c13692455d4832269810/] [crayon-59c13692455d7917053428/] [crayon-59c13692455d9626235660/] [crayon-59c13692455dc056339178/] [crayon-59c13692455df258108210/] [crayon-59c13692455e1512743691/] [crayon-59c13692455e4175986195/] [crayon-59c13692455e7986404329/] [crayon-59c13692455ea289152364/] [crayon-59c13692455ec553848498/] [crayon-59c13692455ef653396739/] [crayon-59c13692455f2244839608/] [crayon-59c13692455f4589838536/] [crayon-59c13692455f7473509008/] [crayon-59c13692455f9571032183/] [crayon-59c13692455fc284588395/] [crayon-59c13692455ff342828314/] And have a great Day Kåre

By | 2017-08-22T13:05:40+00:00 November 13th, 2012|Automation, Operations Manager (SCOM), Powershell|3 Comments

Eject CD script, quarantined by FEP! PowerShell to the rescue!

I guess everyone knows that you can’t enable BitLocker on a machine from a Task Sequence if there is a CD in the CD drive… The workaround is quit simple, just run a script to eject the cd drive before running the “enable BitLocker” step. Well the other day this script, a vbs, I use, was removed by Forefront.. I guess the heuristic scan evaluated the content of the script to be unsafe, and quarantined it.. This is obviously not good, as it’s needed by the task sequence… So I thought, maybe there is a way to eject the CD [...]

By | 2012-03-22T12:25:53+00:00 March 22nd, 2012|General info, OS Deployment, Powershell, Security|3 Comments

Small useful scripts–Changing Driver Package source (PS1)

I have this customer who had to move all driver packages from from one server a another. This of cause meant all the Data Source references had to be change as well. Once al the packages were moved to the new server I ran the following  two scripts to change the source. All you need to change is the $Site to your site code, or add it is a parameter when you run the script. You will obviously also have to type in the old and new path. Syntax: Script.ps1 –Site XXX If you want to only run against one [...]

WMI/ConfigMgr Scripting: CreateEmbeddedObjectInstance (.NET) or SpawnInstance (VBScript) in PowerShell

  During the development of the script I posted yesterday, I noticed that a lot of people had problem discovering how to create WMI objects in PowerShell. I found different suggestions, but they all had problems. When I have to create WMI object instances I use this this method, which I used in my old script about sharing folders here is an example: [crayon-59c1369249454319060668/] using configuration manager development we have to create a lot of wmi objects. Take a look at this SDK Sample in the VBScript example we have this line: [crayon-59c1369249468051954099/]   and in the C# example it [...]

System Center Orchestrator 2012 Beta: Using Run .Net Script Activity – PowerShell: Inputting and Returning Data

This article describes how to use the Run .Net Activity to run PowerShell Scripts. I have created an example runbook which does the following: Start once every minute. Read a text file containing a list of sites/servers. Parse the list to PowerShell script. PowerShell script tried to ping each address and get the response time. PowerShell script output formatted HTML, ready to put inside a HTML Table, containing the addresses and response time. Runbook writes a web site based on a HTML template. The result is a website, in my case it looks like this: NB! some websites/server [...]

Exchange and Activesync: Limiting the mailbox to sync with only one device

Just came back from a customer which needed to limit the number of mobile device to one per mailbox. For this implementation the customer used all kind of smart phones, so the challange was also to find the unique Device ID from the Smartphone and add it to a Active Directory Attribute called: msExchMobileAllowedDeviceIDs. I created a Powershell script which read a text file and add the ID to AD. The script is also adding a dummy ID for all other mailboxes. It could also be disabled but the customer was more satisfied with the error from a wrong device [...]

By | 2011-05-17T12:04:59+00:00 May 17th, 2011|Powershell|0 Comments