# encoding: ascii
# api: powershell
# title: Deploy Folder
# description: This will pull a list of computers from AD and copy a folder to that system.
# version: 0.1
# author: HughS
# license: CC0
# x-poshcode-id: 3018
# x-archived: 2016-04-27T16:43:47
# x-published: 2012-10-21T10:14:00
#
# I tried creating a shortcut to that folder on each users desktop but that didn’t work out. I’m using a login script to copy a premade shortcut to the users desktop. I’m deploying Training materials to user’s systems so that is where this came from. I hope it helps you.
#
Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue #This is needed to pull computers from AD
Clear-Host
$Skipped = @() #Create Array for Skipped Computers
$Finished = @() #Create Array for Finished Computers
$Offline = @() #Create Array for Offline Computers
$Computers = Get-QADComputer -SearchScope Subtree -SearchRoot "OU=Workstations,DC=ins-lua,dc=com" #Get Computers from AD
FOREACH ($Computer in $Computers) #Process Computers
{
$ObjComputerName = New-Object PSObject
$ObjComputerName = $Computer.name
$System = $ObjComputerName
IF (Test-Connection -ComputerName $System -Quiet -Count 1) #Tests to see if computer is online
{
IF (Test-Path "\\$System\C$\Users\Public") #This would indicate Windows 7 OR Vista
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Users\Public" -Recurse -Force
Write-Host "Finished Win7 System $System"
$Finished += $System
}
ELSE
{
IF (Test-Path "\\$System\C$\Documents and Settings\All Users")
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Documents and Settings\All Users" -Recurse -Force
Write-Host "Finished WinXP System $System"
$Finished += $System
}
}
}
ELSE
{
$Skipped += $System
}
}
FOREACH ($System in $Skipped) #Process Skipped Computers
{
IF (Test-Connection -ComputerName $System -Quiet -Count 1)
{
IF (Test-Path "\\$System\C$\Users\Public")
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Users\Public" -Recurse -Force
Write-Host "Finished Win7 System $System"
$Finished += $System
}
ELSE
{
IF (Test-Path "\\$System\C$\Documents and Settings\All Users")
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Documents and Settings\All Users" -Recurse -Force
Write-Host "Finished WinXP System $System"
$Finished += $System
}
}
}
ELSE
{
$Offline +=$System
}
}
Write-Host "Offline Systems: $Offline"
Write-Host "Finished Systems: $Finished"