Tested PrinterPurge and updated apps to work with VMs
This commit is contained in:
parent
433d89c8b9
commit
2bac7ba34e
|
|
@ -25,7 +25,7 @@
|
||||||
Sort-Object -Property DisplayName
|
Sort-Object -Property DisplayName
|
||||||
} else {
|
} else {
|
||||||
#Checks if pc is online so Invoke doesn't hang on offline pc
|
#Checks if pc is online so Invoke doesn't hang on offline pc
|
||||||
if (Test-Connection -ComputerName $comp -Count 1) {
|
if (Test-Connection -ComputerName $ComputerName -Count 1) {
|
||||||
$localapps = Invoke-Command -ComputerName $ComputerName -SessionOption $(New-PSSessionOption -MaxConnectionRetryCount 1 -NoMachineProfile) -ScriptBlock {
|
$localapps = Invoke-Command -ComputerName $ComputerName -SessionOption $(New-PSSessionOption -MaxConnectionRetryCount 1 -NoMachineProfile) -ScriptBlock {
|
||||||
Get-Package -ProviderName Programs -IncludeWindowsInstaller |
|
Get-Package -ProviderName Programs -IncludeWindowsInstaller |
|
||||||
Select-Object @{N='DisplayName';E={$_.Name}} |
|
Select-Object @{N='DisplayName';E={$_.Name}} |
|
||||||
|
|
@ -51,7 +51,11 @@
|
||||||
$apps += $a
|
$apps += $a
|
||||||
|
|
||||||
# Grab apps that are only returned by local query
|
# Grab apps that are only returned by local query
|
||||||
|
if ($out) {
|
||||||
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
|
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
|
||||||
|
} else {
|
||||||
|
$localOnly = $localapps
|
||||||
|
}
|
||||||
foreach ($item in $localOnly) {
|
foreach ($item in $localOnly) {
|
||||||
$a = New-Object -TypeName PSCustomObject
|
$a = New-Object -TypeName PSCustomObject
|
||||||
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
|
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,21 @@
|
||||||
# Removes printer from all online computers. Useful when printer drivers
|
# Removes printer from all online computers. Useful when printer drivers
|
||||||
# change to force users to install new drivers
|
# change to force online users to install new drivers
|
||||||
function Invoke-PrinterPurge ($printer) {
|
function Invoke-PrinterPurge ($printer) {
|
||||||
$comps = HostnamesByPrinter($printer)
|
$comps = HostnamesByPrinter($printer)
|
||||||
# confirm step?
|
if (-not ($comps -is [array])) {
|
||||||
|
$comps = @($comps)
|
||||||
|
}
|
||||||
|
$res = Read-Host "$($comps.Length) computers found, remove $printer from all of them? (y/N)"
|
||||||
|
if (-not ($res -match "^[yY]")) { return }
|
||||||
for ($i = 0; $i -lt $comps.Length; $i += 1) {
|
for ($i = 0; $i -lt $comps.Length; $i += 1) {
|
||||||
$comp = $comps[$i]
|
$comp = $comps[$i]
|
||||||
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -PercentComplete (100*$i / $comps.Length) -CurrentOperation $comp
|
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -PercentComplete (100*$i / $comps.Length) -CurrentOperation "$comp $i/$($comps.Length)"
|
||||||
if ($comp -like "*EPIC*") { continue }
|
if ($comp -like "*EPIC*") { continue }
|
||||||
if (-not (Test-Connection $comp -Count 1)) {
|
if (-not (Test-Connection $comp -Count 1)) {
|
||||||
Write-Output "$printer | $comp Offline"
|
Write-Output "$printer | $comp Offline"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
# Remove-Printer $printer -ComputerName $comp -AsJob
|
Remove-Printer $printer -ComputerName $comp -AsJob
|
||||||
Write-Output "$printer | $comp Job Sent"
|
Write-Output "$printer | $comp Job Sent"
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -Completed
|
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -Completed
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue