December 2nd: Part 2: Uninstall Java (or any other software) with ConfigMgr Compliance Baselines

It's December 2nd and Christmas is just around the corner! Yesterday Jakob kicked off the Coretech December Calendar with a great post about "Triggering a webhook from a SharePoint workflow using Out-of-the-box Activities" (Check out his blog post here: http://bit.ly/1N16fte).  That was the  first, this is the second post in the Coretech blog series that will continue until December 24th - Christmas Eve! :) In Part 1 (http://bit.ly/1PlnDPr) I explained how you can utilize ConfigMgr Compliance Baselines for uninstalling software like Java, Adobe etc. with the help of PowerShell and WMI. Well in Part 1 we used the Win32_Product class which is not recommended [...]

Part 1: Uninstall Java (or any other software) with ConfigMgr Compliance Baselines

Compliance Items and Compliance Baselines in ConfigMgr is so powerful! And with some PowerShell magic you can almost use it to do anything you like on a Windows based computer – Only your imagination that will be the showstopper! Here I will show how you can uninstall software using WMI and Compliance Items in SCCM. However, it is important that you read the following articles as the uninstallation process uses win32_product WMI class which is known for its evilness. Thanks to Kaido, Jürg and Torsten for pointing this one out. A updated post as been created using a better and more [...]

Upgrade System Center Configuration Manager Console with PowerShell

Since Service Pack 1 was released to SCCM 2012 R2 I have been upgraded several environments. A couple of customers wanted me to create a PowerShell script to uninstall existing ConfigMgr Console and install the new updated version with the latest cumulative updates and hotfixes. If you create a package to distribute it with SCCM make sure you point the Data source to the location of the Client installations files, Script, KB3084586-msp and kb3074857-msp. Installation command for the program will then be: PowerShell.exe -file "script.ps1". Remember to set PowerShell execution policy to "Bypass" under Client Settings. This will not affect [...]

By |2015-09-17T18:14:33+01:00september 17th, 2015|Configuration Manager (SCCM), General info, Powershell, Scripting & Development|Kommentarer lukket til Upgrade System Center Configuration Manager Console with PowerShell

Automate Signature And Status Reports With PowerShell – Windows Defender (.txt file)

What you will be able to after reading this blog: Get the latest information about "your" Signature- & Anti Virus reports in Windows Defender and make it into a text file. How to automate it, so it will run every day and give you a status report with time and date. Being able to look at what time and date the latest updates have been completed. First of all, we have to create a folder/directory where the status reports can be stored in. Open up PowerShell in administrative mode and run this script only by copy-paste: $path="C:\" New-Item .\AVStatusReports -ItemType [...]

PowerShell Script That Creates A Folder And A Shortcut On Your Desktop

Basic example of a script that creates a folder in your Local Disk "C"  and then makes a shortcut on desktop so you have easy access to the folder. First of all, open your powershell as administrator and make sure you are at a place where you are able to create folders such as the C:\ drive. PS C:\WINDOWS\system32> cd .. PS C:\WINDOWS> cd .. PS C:\> And now you are able to run the script! - Copy and paste what is written below $path = "C:\" New-Item .\EpicFolder -ItemType Directory -Force $wshshell = New-Object -ComObject WScript.Shell $desktop = [System.Environment]::GetFolderPath('Desktop') [...]

By |2015-09-14T14:21:32+01:00september 14th, 2015|General info, Powershell, Scripting & Development|Kommentarer lukket til PowerShell Script That Creates A Folder And A Shortcut On Your Desktop

Azure Automation DSC: How to register and use Azure Automation DSC

One of the new features of Azure Automation is still somewhat hidden. It needs to be enabled before you see it in the GUI This blog post gives a quick overview of what is needed to use it.   Step 1: Enable the extension in your Azure Account #Add & Select Account Add-AzureAccount Switch-AzureMode -Name AzureResourceManager #Register DSC extension on account Register-AzureProvider –ProviderNamespace Microsoft.Automation Register-AzureProviderFeature -FeatureName dsc -ProviderNamespace Microsoft.Automation The command registers the azure automation dsv extension on your account. This shows the DSC Nodes tile in your automation account:     Step 2: Select subscription and default values Before [...]

PowerShell: LEAP Motion PowerShell Lottery Script @ Danish PowerShell User Group

In our geek club aka The Danish PowerShell user group, we always do a lottery in the end, for books or similar. To draw the correct winner we have been using a script that I have developed. I have for a long time, promised to release the script so that other user groups or other interested people can use it for fun! It has amazing ascii graphics and colors!!! It will take you straight back to your C64 loading screen! The script is a lottery script that takes a file from www.eventbrite.com containing all attendees. The script need a LEAP [...]

By |2015-06-22T14:59:47+01:00juni 22nd, 2015|Powershell, Scripting & Development|Kommentarer lukket til PowerShell: LEAP Motion PowerShell Lottery Script @ Danish PowerShell User Group

Windows Server 2016 Technical Preview 2 ADFS New PowerShell cmdlets

Quick comparison shows that we have 37 new PowerShell cmdlets :) cmdlet name Add-AdfsLocalClaimsProviderTrust                                                                           Add-AdfsScopeDescription                                                                                   Add-AdfsTrustedFederationPartner                                                                           Disable-AdfsCertificateAuthority                                                                           Disable-AdfsLocalClaimsProviderTrust                                                                       Enable-AdfsLocalClaimsProviderTrust                                                                        Get-AdfsAccessControlPolicy                                                                                Get-AdfsApplicationPermission                                                                              Get-AdfsAzureMfaConfigured                                                                                 Get-AdfsCertificateAuthority                                                                               Get-AdfsLocalClaimsProviderTrust                                                                           Get-AdfsRelyingPartyWebTheme                                                                               Get-AdfsScopeDescription                                                                                   Get-AdfsTrustedFederationPartner                                                                           Grant-AdfsApplicationPermission                                                                            Invoke-AdfsFarmBehaviorLevelRaise                                                                          New-AdfsAccessControlPolicy                                                                                New-AdfsAzureMfaTenantCertificate                                                                          New-AdfsLdapAttributeToClaimMapping                                                                        New-AdfsLdapServerConnection                                                                               Remove-AdfsAccessControlPolicy                                                                             Remove-AdfsLocalClaimsProviderTrust                                                                        Remove-AdfsRelyingPartyWebTheme                                                                            Remove-AdfsScopeDescription                                                                                Remove-AdfsTrustedFederationPartner                                                                        Restore-AdfsFarmBehaviorLevel                                                                              Revoke-AdfsApplicationPermission                                                                           Set-AdfsAccessControlPolicy                                                                                Set-AdfsApplicationPermission                                                                              Set-AdfsAzureMfaTenant                                                                                     Set-AdfsCertificateAuthority                                                                               Set-AdfsLocalClaimsProviderTrust                                                                           Set-AdfsRelyingPartyWebTheme                                                                               Set-AdfsScopeDescription                                                                                   Set-AdfsTrustedFederationPartner                                                                           Test-AdfsFarmBehaviorLevelRaise                                                                            Test-AdfsFarmBehaviorLevelRestore   Best

By |2017-08-22T10:22:02+01:00maj 13th, 2015|Powershell, Windows Server|Kommentarer lukket til Windows Server 2016 Technical Preview 2 ADFS New PowerShell cmdlets

Azure RMS PowerShell cmdlets

Here are the Azure RMS PowerShell cmdlets excel sheet. There are totally 44 cmdlets in AADRM Module. You can download the Azure Rights Management Administration Tool from here You can download this excel sheet from here [download id="249"]

By |2017-08-22T10:17:14+01:00april 9th, 2015|Azure, Powershell|Kommentarer lukket til Azure RMS PowerShell cmdlets

Create Status Filter Rules with PowerShell

Here is a quick example of creating a Status Filter Rule in Configuration Manager with PowerShell #Example 1 New-CMStatusFilterRule -SiteCode PS1 -Name 'Remove PC from OSD Collection' -MessageId 11144 -MessageType Milestone ` -RunProgram $True -ProgramPath 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Scripts\Remove-CMDeviceFromCollection.ps1 -CollectionName "OSD Windows 8 Standard" -ComputerName %msgsys' #Example 2 $Parameters = @{ SiteCode = 'PS1' Name = 'Remove PC from OSD Collection' MessageId = 11144 MessageType = 'Milestone' RunProgram = $True ProgramPath = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Scripts\Remove-CMDeviceFromCollection.ps1 -CollectionName "OSD Windows 8 Standard" -ComputerName %msgsys' } New-CMStatusFilterRule @Parameters Execute the code     Happy Scripting

By |2015-03-23T13:16:47+01:00marts 23rd, 2015|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Create Status Filter Rules with PowerShell

Beyond unsupported – How to add PowerShell ISE to ConfigMgr Admin Console

As you already know, then currently we can only start PowerShell Console through Configuration Manager Admin Console but most likely  you may want to start PowerShell ISE through Admin Console :) Step-by-step guide First, this is not supported so don’t blame me if something is not working. Please also remember that there is no SAVE button in Admin Console Builder Tool! Close ConfigMgr Admin Console Start AdminUI.ConsoleBuilder.exe – You can find this tool under the Admin Console installation folder   Select File –> Open –> ConnectedConsole Select View->Application Menu Items Select Connect via Windows PowerShell and right-click select Clone Now [...]

Working with Queries in ConfigMgr with PowerShell

I accidentally blew up my dev lab and now I need to build a new one but luckily we have PowerShell :). In this picture we have 8 Queries and I would like to create Device Collections based on these Queries. These Queries are built with Servicing Extension.   Here are some of the commands that we can use in Configuration Manager 2012 R2 CU4. These commands allows us easily export/import Queries from one system to another and much more. #Import Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" #Get all CM Queries $Queries = Get-CMQuery #Total Queries [...]

Quick intro to Configuration Items in ConfigMgr with PowerShell

Configuration Items that I would like to export and import   Here are some command examples that we can use in Configuration Manager 2012 R2 CU4. #Import Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" #Get all CIs $ConfigurationItems = Get-CMConfigurationItem #Total CIs $ConfigurationItems.Count #Get CIs only with specific keyword $ConfigurationItems = Get-CMConfigurationItem -Name "*CT - *" -ForceWildcardHandling #CI rules with 'CT - ' keyword - 12 CIs in this example $ConfigurationItems.Count #Export out CIs with 'CT - ' keyword foreach($CI in $ConfigurationItems){ Write-Output -InputObject "Exporting out $($CI.LocalizedDisplayName) CI" Export-CMConfigurationItem -Path "$env:USERPROFILE\Desktop\CI_Rules\$($CI.LocalizedDisplayName).cab" -InputObject $CI } #New CI folder [...]

By |2015-03-16T09:50:54+01:00marts 16th, 2015|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Quick intro to Configuration Items in ConfigMgr with PowerShell

New ConfigMgr PowerShell cmdlets in CU4

Microsoft just released a new CU for Configuration Manager and with latest CU we got 35 PowerShell cmdlets. Now we have 597 PowerShell cmdlets. Here are the new ones: Add-CMDeploymentTypeDependency Add-CMDeploymentTypeSupersedence ConvertFrom-CMApplication ConvertFrom-CMConfigurationItem ConvertTo-CMApplication ConvertTo-CMConfigurationItem Get-CMCertificate Get-CMClientOperation Get-CMDeploymentTypeDependency Get-CMDeploymentTypeDependencyGroup Get-CMDeploymentTypeSupersedence Get-CMMigrationSource Get-CMObjectSecurityScope Get-CMQuery Get-CMSiteRole Invoke-CMGroupDiscovery Invoke-CMQuery Invoke-CMSystemDiscovery Invoke-CMUserDiscovery New-CMADGroupDiscoveryScope New-CMDeploymentTypeDependencyGroup New-CMEmbeddedObjectInstance New-CMEmbeddedProperty New-CMEmbeddedPropertyList New-CMQuery Remove-CMCollection Remove-CMDeploymentTypeDependency Remove-CMDeploymentTypeDependencyGroup Remove-CMDeploymentTypeSupersedence Remove-CMQuery Set-CMDeploymentTypeDependency Set-CMDeploymentTypeDependencyGroup Set-CMDeploymentTypeSupersedence Set-CMQuery Sync-CMMigrationSource   Happy Scripting! :)

Create ConfigMgr Collections and Admin Console Folders with PowerShell

Starting from ConfigMgr 2012 R2 we can use New-Item PowerShell cmdlet to create ConfigMgr Admin Console folders. Here is one simple and quick PowerShell script that allows you to create folders and Collections and finally it moves the Collection to correct folder. #Step 1 Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" #Step 2 New-Item -Name 'OSD' -Path 'PS1:\DeviceCollection' New-Item -Name 'Mobile Device Management' -Path 'PS1:\DeviceCollection' New-Item -Name 'Power Management' -Path 'PS1:\DeviceCollection' New-Item -Name 'ViaMonstra' -Path 'PS1:\DeviceCollection' New-Item -Name 'Software Updates' -Path 'PS1:\DeviceCollection' New-Item -Name 'Compliance' -Path 'PS1:\DeviceCollection' #Step 3 New-CMDeviceCollection -Name 'Test 1' -LimitingCollectionName 'All Systems' New-CMDeviceCollection -Name [...]

Service Manager powershell snippets

Merry x-mas! In today’s December calendar tips & trick I'm going to a post some useful powershell snippets for Service Manager. As we all know, the December 11th is the special day where the Bethlehem-powershell star outshined all the others.        The scripts here is mostly for administrative purposes. They are of course provided “as-is” so feel free to expand/optimize/ include more error handling etc. Create Management Pack UPDATE: Script now works with different windows localization. Default language will now be set according to the console language user preference and not the windows locale Unfortunately we are not [...]

By |2014-12-11T09:36:00+01:00december 11th, 2014|Powershell, Service Manager (SCSM)|Kommentarer lukket til Service Manager powershell snippets

Get Direct Collection Memberships And Machine Variables Information

On several occasions I have had the need to pull information on SCCM devices, and recently I was asked to do a backup of all client direct memberships and some specific machine variables. So I thought I would share my latest version of a script that does that. The script takes an argument that will allow you to limit the process to only a set of named clients or just one if you prefer. Param($clients) The script starts by create a class to contain the information pulled from SCCM, making it easier to work with afterwards. Add-Type -Language CSharpVersion3 @" [...]

By |2014-12-10T00:02:00+01:00december 10th, 2014|Configuration Manager (SCCM), General info, Powershell|Kommentarer lukket til Get Direct Collection Memberships And Machine Variables Information

How to populate object properties with data from a database using PowerShell

  You probably know how you can use a registry discovery to populate properties on windows computer instances, but what if you already have the data in SQL database/CMDB and want to avoid having to first write the data to the registry and then use a discovery to get the data into SCOM? Or what if the objects are not windows computers and hence the registry method is not an option? The solution is to use PowerShell to read  the data from the database and then update the objects in SCOM. This post will show you how to do this [...]

By |2014-12-09T04:09:00+01:00december 9th, 2014|Operations Manager (SCOM), Powershell|Kommentarer lukket til How to populate object properties with data from a database using PowerShell

Change device ownership in Configuration Manager with PowerShell

All newly enrolled devices are enrolled as Personal Devices by default in Configuration Manager and we cant change the default behavior. If the Device Ownership is Company, then we can inventory all the installed applications and we can also do mandatory installations. If the Device Ownership is Personal, then we can inventory only applications that are installed through Company Portal. If your company policy is that all the devices must be company-owned, then you can use this script to query a specific collection devices and it will set the Device Ownership to Company. Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE [...]

Configuration Manager 2012 SP1 and R2 PowerShell Provider

Updated 23.03.2015! As you might have already noticed that Configuration Manager PowerShell Provider is lot like Active Directory, Registry etc. provider. To run a cmdlet you need to be inside CMSITE. If you are still using SP1+, then: 1. you can´t use New-Item cmdlet to create folders 2. you can´t set the location to sub folders 3. Get-ChildItem does not work at all If you are using R2+, then 1. You can use New-Item to create folders 2. You can change the location i.e. sub folders etc. 3. Get-ChildItem only prints out folder objects but not collections, applications etc. inside [...]

By |2014-09-30T10:13:45+01:00september 30th, 2014|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Configuration Manager 2012 SP1 and R2 PowerShell Provider