PowerShell Deployment Toolkit: Windows Azure Pack install fails

I am a big fan of PDT but I have been trying to install Windows Azure Pack and the complete system center using PowerShell Deployment Toolkit Using the newest version (currently version 2.64.2611) it fails installing the Windows Azure Pack components! Luckily i found the error: Use a password for the installer user that follows the rules for Windows Azure Pack Minimum 8 chars Include at least one upper case letter and one lower case. include at least one number Include at least one non-alphanumeric. (In my case i was missing this! .. so added a ! to the password) [...]

By |2014-09-23T14:16:47+01:00september 23rd, 2014|Powershell, Windows Azure Pack (WAP)|2 Comments

Scripts and links from my sessions @IT/Dev connections

A big thanks to all who attended at our sessions. Below are the links to the scripts and blog post we referenced during the session. Hope to see you all again next year! Managing Configuration Manager with PowerShell [download id="217"] Building Custom Tools Using PowerShell [download id="216"] Truly Better Together: Configuration Manager 2012 R2 and PowerShell [download id="215"] Quick and Dirty – Build Configuration Manager 2012 Admin Console Extensions automatically - http://cm12sdk.net/?p=2299 Configuration Manager 2012 R2 Developer Excel Sheet - http://cm12sdk.net/?p=2326 Does Your Hard Work Advance the Ecosystem? - http://blogs.msdn.com/b/powershell/archive/2011/02/07/does-your-hard-work-advance-the-ecosystem.aspx Coretech Collections Tool - https://blog.ctglobalservices.com/kaj/coretech-configuration-manager-2012-r2-powershell-automation-module-0-1/ Before you start using these script examples on your production environment, please make [...]

By |2014-09-21T20:10:39+01:00september 21st, 2014|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Scripts and links from my sessions @IT/Dev connections

Store encrypted password in a PowerShell script

I write a lot of PowerShell scripts where I need to access different kinds of services, servers and databases. Often these scripts needs to run on schedules in the background and so on. Instead of having cleartext passwords scattered throughout the scriptfile I like to store a securestring version of the password in the script. Normally you would build a credential object using something like this $username = "domain\admin" $password = "password" | ConvertTo-SecureString -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password That means that anyone who can open and read the scriptfile, will know what the password [...]

By |2017-09-07T22:55:56+01:00september 10th, 2014|Powershell|17 Comments

Generate Random Timeslot for scheduled tasks

I was tasked to create a PS script that created a Windows Server Backup policy with a random start time I came up with the following script for the random start time bits. function Get-TimeSlot($startTime, $EndTime) { $timeslots = @() for ($i = $startTime; $i -ne $EndTime; $i++) { if ($i -eq 24) { $i = 0 } $timeslots += $i } $timeslot = "$(Get-Random $timeslots):00" return $timeslot } Get-TimeSlot -startTime 20 -EndTime 4 There might be a more Powershell’ish way of doing this, but it gets the job done.

By |2018-01-24T23:11:07+01:00september 10th, 2014|Powershell|3 Comments

Coretech Configuration Manager 2012 R2 PowerShell automation module 0.1

During the TechEd Kent showed one of our solution that allows you to save all the Collections to an Excel file or to create Collections based on Excel template. We have received a lot of emails and twitter tweets that when we are going to publish it and good news is that we will publish it now :) . If you haven't seen the Kent TechEd video, then I recommend to watch it before you use this module. This is not the latest version and it is work in progress release. We will continue to improve this PowerShell module. Here [...]

Working with Security Scopes in Configuration Manager with PowerShell

Last year @MMS Kent showed our automated RBA solution and I just discovered that this does not work in ConfigMgr 2012 R2 CU1 environment. It seems like they have changed the process behind the UI and in ConfigMgr 2012 R2 CU1 environment they are using different IDs to identify the Object. Before they used FolderTypeID value but now they are using SecuredTypeID values. You will need these values, if you are working with SMS_SecuredCategoryMemberShip WMI class and AddMemberShips/RemoveMemberships mehtods FolderTypeID FolderTypeName SecuredTypeID 2 SMS_Package 2 7 SMS_Query 7 9 SMS_MeteredProductRule 9 11 SMS_ConfigurationItem 11 14 SMS_OperatingSystemInstallPackage 14 16 SMS_VhdPackage 16 [...]

Find OpenSSL files with SCOM (Heartbleed)

OpenSSL for Windows are two DLL files which could be installed on some of your windows servers. The two files are: libssl32.dll or libssl64.dll and I am not saying these should be removed – but perhaps updated.   Powershell Script You could find the two files either by a powershell script like this one: – Start the script like : FindFile.ps1 libssl32.dll, libssl64.dkk and it will create an event for every finle found. 1: Param([String[]] $FileName) 2:   3: $api = new-object -comObject 'MOM.ScriptAPI' 4:   5: $Drives = Get-psdrive -psprovider "FileSystem" | select name 6: ForEach ($File in $FileName) [...]

How to change Configuration Manager Hardware Inventory Schedule Client Setting

Today I tried to modify Hardware Inventory Schedule client setting and it didn't work. First I thought that I did something wrong or the cmdlet is broken. Here is the cmdlet Verbose output Then I thought that, lets disable the HW client setting and then enable the HW client setting with correct schedule and Bingo it worked correctly. #Step 1 $ClientSettingsName = 'HW Settings' Set-CMClientSetting -Name $ClientSettingsName -EnableHardwareInventory $false -Verbose -Debug #Step 2 $CMWeeklySchedule = New-CMSchedule -RecurCount 1 -RecurInterval Hours Set-CMClientSetting -InventorySchedule $CMWeeklySchedule -Name $ClientSettingsName -EnableHardwareInventory $True -Verbose -Debug If you compare the verbose outputs, then you will see the [...]

Export out User Device Affinity Relationship with PowerShell

This script allows to export out specific collection UDA Relationships to a CSV file. Here is the script it self. Run it on your Primary Site Server and then open the CSV file with Excel. <# .Synopsis This script exports out specific collection UDA Relationships .DESCRIPTION .EXAMPLE Export-CMUDARelationships.ps1 -DeviceCollectionName "All Systems" -OutPut C:\Scripts\Reports\UDA.csv -SiteCode PS1 .NOTES Developed by Kaido Järvemets, Coretech A/S Version 1.0 #> Param( [Parameter(Mandatory=$True,HelpMessage="Please Enter ConfigMgr Collection Name",ParameterSetName='CSV')] $DeviceCollectionName, [Parameter(Mandatory=$True,HelpMessage="Please Enter CSV file location",ParameterSetName='CSV')] $OutPut, [Parameter(Mandatory=$True,HelpMessage="Please Enter ConfigMgr site code",ParameterSetName='CSV')] $SiteCode ) $CollectionQuery = Get-CimInstance -Namespace "Root\SMS\Site_$SiteCode" -ClassName "SMS_Collection" -Filter "Name='$DeviceCollectionName' and CollectionType='2'" $ResourcesInCollection = Get-CimInstance -Namespace [...]

The EASY WAY – List objects in specific folder in Configuration Manager 2012 with PowerShell

Last week I saw one blog post how to list specific folder objects and I believe that actually there is much easier way to list the objects in specific folder. First we need to figure out the ContainerNodeID which is the folder unique ID. We have several ways to find out the folder unique ID, for example we can run the ConfigMgr Admin console in developer mode or we can use a WMI tool. There are different WMI tools that you can find from the internet or you can simple use the WBEMTEST tool also which is already built-in in [...]

How to move objects in Configuration Manager Admin Console with PowerShell

Starting with Configuration Manager 2012 R2 we have a cmdlet called Move-CMObject. This cmdlet allows to move different objects in Admin Console. We still don't have a cmdlet that allows to create ConfigMgr Admin Console folders but if necessary you can use this code to create folders. Here are 6 different examples How to move objects in ConfigMgr Admin Console # Example 1 $CMCollection = Get-CMDeviceCollection -Name "OSD - Windows 8.1" Move-CMObject -FolderPath "PS1:\DeviceCollection\OSD" -InputObject $CMCollection # Example 2 $CollectionID = "PS10036C" Move-CMObject -FolderPath "PS1:\DeviceCollection\OSD" -ObjectId $CollectionID # Example 3 $ConfigurationItem = Get-CMConfigurationItem -Name "Business Hours" Move-CMObject -FolderPath "PS1:\ConfigurationItem\LOB" -InputObject [...]

Create ConfigMgr 2012 R2 Collections with Powershell

I know we have migrations tools and other built-in options when we want to build a new ConfigMgr environment. But Microsoft have given us Powershell, and there are some really cool cmdlets that we can utilize. I’ve had a couple of examples lately where i had to create 100+ collections from scratch – or basicly from just a list of applications… And instead of doing that by hand i would much rather do it with Powershell, and save my poor fingers alot of clicking and typing. Microsoft have a Technet site where all ConfigMgr 2012 R2 cmdlets are listed and [...]

By |2014-02-18T14:07:36+01:00februar 18th, 2014|Configuration Manager (SCCM), Powershell|6 Comments

Simple workflow for Configuration Manager Client installation

Here is a really simple Configuration Manager Client installation PowerShell workflow. This workflow queries all the clients where ClientType property is NULL. You can easily add logging, scheduling etc. workflow Install-CMClient { Param( $SiteCode, $SiteServer ) $Computers = Get-WmiObject -Namespace "Root\SMS\Site_$($SiteCode)" ` -Query "Select Name from SMS_R_System where ClientType is NULL" -PSComputerName $SiteServer Write-Output -Input "Total computers without Configuration Manager Client:$($Computers.Count)" ForEach -parallel ($item in $Computers){ $Path = "\\$($item.Name)\c$" if(Test-Path -Path $Path) { Write-Output -Input "Copying installation files to $($item.Name) TEMP folder" Copy-Item -Path "\\Terminaator\CMClient" -Destination "\\$($item.Name)\c$\TEMP" -Recurse -Force Inlinescript{ Write-Output -Input "Starting CCMSETUP.EXE on $($Using:Item.Name)" Start-Process -FilePath "C:\TEMP\CCMSETUP.EXE" } [...]

Dealing with Network Printers in Configuration Manager 2012

There are multiple ways how you can add a network printer to a PC and of course you can do that also with Compliance Settings in Configuration Manager. In PowerShell we can use Add-Printer cmdlet and if you don’t have the latest PowerShell version, then you can use Win32_Printer WMI class to add the Printer. If you don’t want to depend on a specific PowerShell version, then maybe the easiest way is to use Win32_Printer WMI Class. Here are the scripts/cmdlets that you can use Discovery Scripts Option 1 Win32_Printer WMI Class query Get-WmiObject -Class Win32_Printer -Filter "Name='\\\\CTTERM\\CTColorPrint01'" | Measure-Object [...]

Why I can’t convert my Windows Server 2012 R2 Core to GUI

Let’s assume that you installed some time ago one Windows Server 2012 R2 Server Core and you have installed also latest Windows Updates to that server and this server does not have an internet connection. Here are the updates that are installed In one day you discover that you need to add graphical user interface and you execute the following command Install-WindowsFeature Server-Gui-Shell -Source:wim:D:\Sources\install.wim:2 You will see that it reaches to 68% and fails with following error Install-WindowsFeature : The request to add or remove features on the specified server failed. Installation of one or more roles, role services, or [...]

By |2014-01-23T11:53:34+01:00januar 23rd, 2014|Operating Systems, Powershell, Windows Server|18 Comments

Installing a Domain Controller on Windows Server 2012 R2 Core

In my previous post I showed how you can install Active Directory Domain Services on Windows Server Core and in this post I´m going to show how you can add an additional Domain Controller to your environment because best practice recommends that you have at least two of them. To add an additional Domain Controller we need to do following: 1. Rename the server 2. Set the IP and DNS address 3. Join the server to domain 4. Install Active Directory Domain Services Server Role 5. Deploy the Domain Controller   Before you continue I recommend to read my first [...]

By |2014-01-21T14:18:27+01:00januar 21st, 2014|Powershell, Windows Server|2 Comments

Capture output from command line tools with PowerShell

A simple task and then again not A customer asked me if it was possible to grab output from a command and analyze the output afterwards. In the particular case he needs to call a telnet session and check if there was a proper response from the server. The easy solution and then again not The very simple solution would be to start the command from PowerShell, redirecting the output to a file, wait for the process to finish and then read the file content. But in this case the process would not end on its own, as the telnet [...]

By |2018-01-24T23:02:52+01:00januar 16th, 2014|Powershell|9 Comments

Set-SCSMTemplateWithActivities powershell script

UPDATE 02-01-2014: Fixed some issues in script   When dealing with the cmdlet: Set-SCSMTemplate in SMLets, you might have noticed that if you apply a template with activities, the prefix of the ID’s (e.g. RA300 or MA250) is all missing. And it’s the same issue if done via the SDK or Orchestrator. One workaround, described by Lee Berg here: http://www.leealanberg.com/blog/2013/03/13/scsm-automated-service-request-smlets-creation-issues-and-work-arrounds/ is to modify the management pack that contains the template, and then insert the prefix like this: MA{0}. This approach works, but can be quite cumbersome as it takes time to do and also “locks” the template so any modification [...]

How to add Configuration Manager Distribution Point Remotely with PowerShell

If you are trying to add a Configuration Manager Distribution Point remotely you may end up with issue: WARNING: The self-signed certificate could not be created successfully Validation of input parameters failed. Cannot Continue Code example Invoke-Command -ScriptBlock { #Step 1 Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") #Step 2 $SiteCode = Get-PSDrive -PSProvider CMSITE #Step 3 Set-Location "$($SiteCode.Name):\" #Step 4 Add-CMDistributionPoint -SiteSystemServerName TestServer.corp.viamonstra.com -SiteCode $SiteCode.Name ` -ClientConnectionType Intranet -MinimumFreeSpaceMB 50 -PrimaryContentLibraryLocation Automatic ` -SecondaryContentLibraryLocation Automatic -PrimaryPackageShareLocation Automatic -EnablePxeSupport ` -SecondaryPackageShareLocation Automatic -CertificateExpirationTimeUtc ((Get-Date).AddYears(100)) -ErrorAction STOP } -ComputerName CM01.corp.viamonstra.com If you take same code and run it locally on your Primary Site Server, then it [...]

Modify Maintenance Windows with Configuration Manager cmdlets

One of the new features in Configuration Manager 2012 R2 is that you can configure Maintenance Windows only for Software Updates We can configure all these new stuff with ConfigMgr cmdlets also :) #Import ConfigMgr PSH Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") #Get the CMSITE SiteCode $SiteCode = Get-PSDrive -PSProvider CMSITE # Change the connection context Set-Location "$($SiteCode.Name):\" #Apply MW only to Task Sequence $Collection = Get-CMDeviceCollection -Name "MW 2 - LOB Servers" Set-CMMaintenanceWindow -CollectionID $Collection.CollectionID -ApplyToTaskSequenceOnly -Name "TEST 2" #Apply MW only to Software Updates $Collection = Get-CMDeviceCollection -Name "MW 2 - LOB Servers" Set-CMMaintenanceWindow -CollectionID $Collection.CollectionID -ApplyToSoftwareUpdateOnly -Name "TEST 2" #Modify [...]

By |2013-10-18T09:28:43+01:00oktober 18th, 2013|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Modify Maintenance Windows with Configuration Manager cmdlets

Create Maintenance Windows with Configuration Manager cmdlets

Configuration Manager 2012 R2 PowerShell module contains now New-CMMaintenanceWindow cmdlet :) #Import ConfigMgr PSH Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") #Get the CMSITE SiteCode $SiteCode = Get-PSDrive -PSProvider CMSITE # Change the connection context Set-Location "$($SiteCode.Name):\" #Occurs day 3 of every 2 months effective 10/17/2013 1:00 PM $Schedule = New-CMSchedule -DurationCount 1 -DurationInterval Hours -RecurCount 2 -DayOfMonth 3 -Start ([Datetime]"13:00") $Collection = Get-CMDeviceCollection -Name "MW 1 - Windows Servers" New-CMMaintenanceWindow -CollectionID $Collection.CollectionID -Schedule $Schedule -Name "TEST 1" #Occurs the First Thursday of every 2 months effective 10/17/2013 1:00 PM $Schedule = New-CMSchedule -DurationCount 1 -DurationInterval Hours -RecurCount 2 -DayOfWeek 4 -WeekOrder First -Start [...]

New cmdlets in Configuration Manager 2012 R2

Here are the new cmdlets in Configuration Manager 2012 R2. Now we have totally 560 cmdlets Copy-CMClientAuthCertificateProfileConfigurationItem Copy-CMRemoteConnectionProfileConfigurationItem Copy-CMTrustedRootCertificateProfileConfigurationItem Copy-CMVpnProfileConfigurationItem Copy-CMWirelessProfileConfigurationItem Get-CMAccessLicense Get-CMClientAuthCertificateProfileConfigurationItem Get-CMClientOperations Get-CMDeviceVariable Get-CMInitialModifiableSecuredCategory Get-CMMaintenanceWindow Get-CMRemoteConnectionProfileConfigurationItem Get-CMRemoteConnectionProfileConfigurationItemXmlDefinition Get-CMTrustedRootCertificateProfileConfigurationItem Get-CMVhd Get-CMVpnProfileConfigurationItem Get-CMWirelessProfileConfigurationItem Invoke-CMClientNotification Invoke-CMContentValidation Invoke-CMDeviceRetire Invoke-CMDeviceWipe Move-CMObject New-CMClientAuthCertificateProfileConfigurationItem New-CMDeviceVariable New-CMMaintenanceWindow New-CMRemoteConnectionProfileConfigurationItem New-CMTrustedRootCertificateProfileConfigurationItem New-CMVhd New-CMVpnProfileConfigurationItem New-CMWirelessProfileConfigurationItem Publish-CMPrestageContentTaskSequence Remove-CMClientAuthCertificateProfileConfigurationItem Remove-CMContentDistribution Remove-CMDeviceVariable Remove-CMMaintenanceWindow Remove-CMRemoteConnectionProfileConfigurationItem Remove-CMTrustedRootCertificateProfileConfigurationItem Remove-CMVhd Remove-CMVpnProfileConfigurationItem Remove-CMWirelessProfileConfigurationItem Set-CMAssignedSite Set-CMClientAuthCertificateProfileConfigurationItem Set-CMDeviceOwnership Set-CMDeviceVariable Set-CMMaintenanceWindow Set-CMRemoteConnectionProfileConfigurationItem Set-CMTrustedRootCertificateProfileConfigurationItem Set-CMVhd Set-CMVpnProfileConfigurationItem Set-CMWirelessProfileConfigurationItem Get-CMInitModifiableSecuredCategory

Quick and Dirty – Build Configuration Manager 2012 Admin Console Extensions automatically

I just finished one PowerShell script that queries all the Admin Console XML files and it creates automatically Admin Console Extension. You can use this script to locate correct place for you right-click tool. There are totally 655 Console GUIDs. You can download the script from here  

By |2013-10-15T13:27:20+01:00oktober 15th, 2013|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Quick and Dirty – Build Configuration Manager 2012 Admin Console Extensions automatically

Can you combine Get-WmiObject with ConfigMgr cmdlets? Yes, you can

Last week I discovered that you can create a Refresh Schedule with New-CMSchedule cmdlet and then you can easily use that object with Get-WmiObject cmdlet to query and modify for example Device Collection Refresh Schedule. Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" $Schedule = New-CMSchedule -RecurCount 2 -RecurInterval Days $Collection = Get-WmiObject -Namespace "Root\SMS\Site_PS1" -Class SMS_Collection -Filter "Name='Windows 8.1 OSD'" $Collection.RefreshType = 2 $Collection.RefreshSchedule = $Schedule.psbase.ManagedObject $Collection.Put() You can create the Device Collection with correct Refresh Schedule but Set-CMDeviceCollection cmdlet does not allow to change the Refresh Schedule. $Schedule = New-CMSchedule -RecurCount 2 -RecurInterval Days New-CMDeviceCollection -Name "Windows [...]

By |2013-10-14T10:28:47+01:00oktober 14th, 2013|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Can you combine Get-WmiObject with ConfigMgr cmdlets? Yes, you can