Active Directory – Change Profile Path & Group member

This litte script changes the profile path of a specified OU of AD Users that are in a specific group.

Import-Module ActiveDirectory

$ou = "ou=YOUROU,dc=ad,dc=uclv,dc=net"

$properties = "MemberOf"
$i = 0
Get-ADUser -Filter * -SearchBase $ou -Properties $properties | Where-Object { $_.MemberOf -like "*GROUPNAME*"} |

ForEach-Object {

Write-Host "User:  "$_.SamAccountName -ForegroundColor Yellow
Write-Host "Count: "$i -ForegroundColor Yellow

$ProfilePath = "\\\{0}$\roaming" -f $_.SamAccountName
Write-Host "Path:  "$ProfilePath -ForegroundColor Yellow
Write-Host "-----"
# Set profile path
$result_setprofile = Set-ADUser $_.samaccountname -ProfilePath $ProfilePath
if ($?)
Write-Host "Profile set for user:"$_.samaccountname -ForegroundColor Green
# Set correct groups
Remove-ADGroupMember cluster-migration-roaming $_.samaccountname -Confirm:$false
Add-ADGroupMember cluster-migration-new $_.samaccountname
if ($?)
Write-Host "Groups set for user: "$_.samaccountname -ForegroundColor Green

Print Friendly, PDF & Email

Allow this application to be installed from the Install Application task sequence action without being deployed

To deploy applications from a Task Sequence you must enable on all applications following option:

Allow this application to be installed from the Install Application task sequence action without being deployed

You can do this with a Powershell script:

## Enable Install Application Task Sequence Flag
$name = Get-CMApplication -Name *

ForEach ($item in $name)

Write-Host $item.LocalizedDisplayName -ForegroundColor Red

$item_new = $item.LocalizedDisplayName

Set-CMApplication -AutoInstall $True -Name $item_new -Verbose

Print Friendly, PDF & Email

SCCM 2012 – Past due Applications / Change Deployment

Some Applications on our environment didn’t install. It only shows “Past due”. One workaround i found was on this site:

Thanks to Russ Slaten for this. I changed his script a little bit that you have a second paramter for the Collection Name.


Write-Host "SCCM 2012 SP1 Deadline Time Increment Script"
Write-Host "Version 1.0"
Write-Host "Parameters"
Write-Host "  SiteCode: "$SiteCode -ForegroundColor Green
Write-Host "  CollectionName: "$CollectionName -ForegroundColor Green

function GetCMSiteConnection
  param ($siteCode)

  $CMModulePath = Join-Path -Path (Split-Path -Path "${Env:SMS_ADMIN_UI_PATH}" -ErrorAction Stop) -ChildPath "ConfigurationManager.psd1"
  Import-Module $CMModulePath -ErrorAction Stop
  $CMProvider = Get-PSDrive -PSProvider CMSite -Name $siteCode -ErrorAction Stop
  CD "$($CMProvider.SiteCode):\"
  return $CMProvider


#Connect to SCCM, must have SCCM Admin Console installed for this to work
#If this fails then connect with the console to the site you want to use, then open PowerShell from that console
$CM = GetCMSiteConnection -siteCode $SiteCode
Write-Host "Connected to:" $CM.SiteServer
Write-Host "---Updating Deployments---"

foreach ($Deployment in (Get-CMDeployment -CollectionName $CollectionName))
    Set-CMApplicationDeployment -Application (Get-CMApplication -Id $Deployment.CI_ID) -CollectionName $Deployment.CollectionName -DeadlineDate ($Deployment.EnforcementDeadline).AddMinutes(1) -DeadlineTime ($Deployment.EnforcementDeadline).AddMinutes(1) -Verbose
    Write-Host "  "$Deployment.SoftwareName" - "$Deployment.CollectionName -ForegroundColor Green

Now you can give the Site Code and your Collection Name. All Deployments on this Collection will then be changed. The script increased the Deadline +1 minute.

Print Friendly, PDF & Email

SCCM 2012 – Add / Edit Deployments with Powershell

  • Add a Deployment for an Application (Application Available / User Information)
    Start-CMApplicationDeployment -CollectionName "Collection Name" -Name "Softwarename" -DeployAction Install -DeployPurpose Available -UserNotification DisplayAll -AvaliableDate (Get-Date) -AvaliableTime (Get-Date) -Verbose
  • Add a Deployment for an Application (Application Requierd / No User Information)
    Start-CMApplicationDeployment -CollectionName "Collection Name" -Name "Softwarename" -DeployAction Install -DeployPurpose Required -SendWakeUpPacket $True -UserNotification HideAll -AvaliableDate (Get-Date) -AvaliableTime (Get-Date) -RebootOutsideServiceWindow $True -OverrideServiceWindow $True -Verbose
  • If you have should create more Deployments for an Application following script should help:

    Import-CSV $filepath -Header Software, Room | Foreach-Object{
        Start-CMApplicationDeployment -CollectionName $_.Room -Name $_.Software -DeployAction Install -DeployPurpose Required -SendWakeUpPacket $True -UserNotification HideAll -AvaliableDate (Get-Date) -AvaliableTime (Get-Date) -RebootOutsideServiceWindow $True -OverrideServiceWindow $True -Verbose

    This CSV File has two colums. The first is the Softwarename and the second is the Room (The Room is in my case the Collection Name). To run the script you must before allow scripts with following command:

    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
  • If you want to edit a Deployment follwing command is an example. Please note that the AvailableDate/Time and DeadlineDate/Time is the same. This results in that the Installation Deadline is set to “As soon as possible after the available time”
    Set-CMApplicationDeployment -ApplicationName $_.Software -CollectionName "Collection Name" -AvaliableDate 2014/06/29 -AvaliableTime 11:22 -DeadlineDate 2014/06/29 -DeadlineTime 11:22 -SendWakeUpPacket $True -UserNotification DisplaySoftwareCenterOnly -RebootOutsideServiceWindow $True -OverrideServiceWindow $True -Verbose


Print Friendly, PDF & Email

Powershell – Connect network printers and set default

First create your script. In my example i have two network printers to connect.

Please note: Make sure you have a connection to the printer share and you have saved the username and password.

## Connect first printer
$PrinterPath = "\\\a3c-s401"
$net = new-Object -com WScript.Network

## Connect second printer
$PrinterPath2 = "\\\a4-s401"
$net2 = new-Object -com WScript.Network

## Set default printer
(New-Object -ComObject WScript.Network).SetDefaultPrinter('')

To set the default printer you need the correct printer name. You can get it with following command.

(New-Object -ComObject WScript.Network).EnumPrinterConnections()

Attention: Don’t forget to enable scripts in Powershell. To do this run following command in a Administrator Powershell.

Set-ExecutionPolicy unrestricted

In my case i have to do this every logon. So i create a Task with the following command.




Print Friendly, PDF & Email

Mount Image (.wim) with dism.exe

First of all create a Mountpoint:

md C:\FHVWIN8\Mount

Ater that you can mount your .wim file to the directory with following command:

DISM /Mount-Wim /Wimfile:\\\software$\bw\FHVWIN8.wim /index:1 /Mountdir:C:\FHVWIN8\Mount

Now you can add files and/or add packages. To verify the packages use following command:

DISM /image:C:\FHVWIN8\Mount /Get-Packages

To commit the changes:

DISM /Unmount-Wim /Mountdir:C:\FHVWIN8\Mount /Commit
Print Friendly, PDF & Email