Posts

Showing posts from March, 2016

Stuck @ "Waiting for user logon"

This may or may not be something that you would commonly see in your environment. We only see it occasionally but it used to be a pretty common problem. One of my teammates found a technet forum post that addressed this specifically. Pretty interesting read if you are fighting this issue on a particular client. https://social.technet.microsoft.com/Forums/en-US/1569e1e2-91bc-435d-8998-beb817d5b453/waiting-for-user-logon?forum=configmanagergeneral Here is the meat and potatoes of the forum discussion. $CITask = get-wmiobject -query "select * from CCM_CITask where TaskState != ' PendingSoftReboot' AND TaskState != 'PendingHardReboot' AND TaskState != 'InProgress'" -namespace root\ccm\CITasks if ($CITask -ne $NULL) { $CITask | remove-wmiobject -Whatif $CITask | remove-wmiobject } ELSE { "CCM_CITasks is empty. Nothing to do" }

Create RDL files in mass

I found this script a while back when we were doing some reporting server migrations. Not sure how useful you might find this script as it is a bit dated and I'm sure there are newer calls that can be done to accomplish the same feat. #note this is tested on PowerShell v2 and SSRS 2008 R2 [void][System.Reflection.Assembly]::LoadWithPartialName("System.Xml.XmlDocument"); [void][System.Reflection.Assembly]::LoadWithPartialName("System.IO"); $ReportServerUri = "http://ServerName/ReportServer/ReportService2005.asmx"; $Proxy = New-WebServiceProxy -Uri $ReportServerUri -Namespace SSRS.ReportingService2005 -UseDefaultCredential ; #check out all members of $Proxy #$Proxy | Get-Member #http://msdn.microsoft.com/en-us/library/aa225878(v=SQL.80).aspx #second parameter means recursive $items = $Proxy.ListChildren("/", $true) | `          select Type, Path, ID, Name | `          Where-Object {$_.type -eq "Report"}; #create a

Redistribute Specific Package on Specific DP

A simple little script to refresh content on a DP. The script uses a list of PackageIDs (yes even applications have a package id). The script also uses part of the DP server name to identify it. Import-Module -Name "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" cd DEV: $a = Get-Content "i:\temp\temp.txt" foreach ($i in $a)     {       $distpoints = Get-WmiObject -Namespace "\\bvlsccmcas\root\SMS\Site_CAS" -Query "Select * From SMS_DistributionPoint WHERE PackageID='$i' AND ServerNALPath like '%PER%'"     foreach ($dp in $distpoints)          {                  $dp.RefreshNow = $true                  $dp.Put()          }     }

Add Machine to a Collection

Here is another simple little script for doing a mass add of Machine Direct rules to a SCCM collection. Note: You will need to have the console installed on the machine that you run this script from due to the powershell cmdlets required. Import-Module -Name "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" $a = Get-Content "i:\temp\temp.txt" foreach ($i in $a)     {     $i | Out-File -FilePath c:\temp\assignout.log -Append     $device = get-cmdevice -Name $i     Add-CMDeviceCollectionDirectMembershipRule -CollectionName "Collection Name" -Resource $device | Out-File -FilePath c:\temp\assignout.log -Append     }

Add Computers to AD Group

Here is a simple little script for adding a mass number of machines to an AD Group. Note: You will need to make sure you have the AD Powershell module installed on the machine you run this on. Import-Module ActiveDirectory $ADGroup = "AdGroup" $Members = Get-ADGroupMember -Identity $ADGroup $Machines = get-content "E:\Powershell Script\AddMachinesToADGroup.txt" $Failures = @() $Added = @() $Existing = @() Foreach ($Machine in $Machines) {     if ($Machine -in $Members.SAMAccountName)     {         $Existing += $Machine     }     else     {         try {             $Machine += "$"             "Trying to Add $($Machine)"             Add-ADGroupMember -Identity $ADGroup -Members $Machine             $Added += $Machine           }         catch { $Failures += $Machine }     } }

Create Prestaged Content and Extract Content

One of my teammates recently created a couple of scripts that we use frequently when doing server migrations and building out new sites. Extract Content $Folder = "Packages" $FolderToSaveTo = "I:\PrestageContent\_Done" if(!(Test-Path $FolderToSaveTo\$Folder)) {New-Item -ItemType Directory -Path $FolderToSaveTo\$Folder} if(!(Test-Path I:\PrestageContent\$Folder\DoIt)) {New-Item -ItemType Directory -Path I:\PrestageContent\$Folder\DoIt} (Get-ChildItem -Path I:\PrestageContent\$Folder -Recurse -Include *.pkgx).Name | ForEach-Object { #$Name = $_ Write-Host "`n" "Files Left: " ((Get-ChildItem -Path I:\PrestageContent\$Folder -Recurse -Include *.pkgx) | Measure-Object).Count "`n" & Write-Host $_.TrimEnd(".pkgx") "`n" & Move-Item I:\PrestageContent\$Folder\$_ I:\PrestageContent\$Folder\DoIt & 'I:\SMS_DP$\sms\Tools\ExtractContent.exe' /P:I:\PrestageContent\$Folder\DoIt /F & Move-Item