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
|
||||
} else {
|
||||
#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 {
|
||||
Get-Package -ProviderName Programs -IncludeWindowsInstaller |
|
||||
Select-Object @{N='DisplayName';E={$_.Name}} |
|
||||
|
|
@ -51,7 +51,11 @@
|
|||
$apps += $a
|
||||
|
||||
# Grab apps that are only returned by local query
|
||||
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
|
||||
if ($out) {
|
||||
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
|
||||
} else {
|
||||
$localOnly = $localapps
|
||||
}
|
||||
foreach ($item in $localOnly) {
|
||||
$a = New-Object -TypeName PSCustomObject
|
||||
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
# 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) {
|
||||
$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) {
|
||||
$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 (-not (Test-Connection $comp -Count 1)) {
|
||||
Write-Output "$printer | $comp Offline"
|
||||
continue
|
||||
}
|
||||
# Remove-Printer $printer -ComputerName $comp -AsJob
|
||||
Remove-Printer $printer -ComputerName $comp -AsJob
|
||||
Write-Output "$printer | $comp Job Sent"
|
||||
}
|
||||
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -Completed
|
||||
|
|
|
|||
Loading…
Reference in a new issue