Refactored places that could use Get-Hostname
This commit is contained in:
parent
f5224ff3fc
commit
b20d2f22a6
|
|
@ -5,17 +5,23 @@ function Invoke-PrinterPurge ($printer) {
|
|||
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 $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
|
||||
|
||||
Write-Output "$printer | $comp Job Sent"
|
||||
}
|
||||
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -Completed
|
||||
|
|
|
|||
|
|
@ -135,10 +135,8 @@
|
|||
New-Item -Path $Destination -ItemType Directory | Write-Verbose
|
||||
} elseif ($site -eq $numSites) {
|
||||
$BackupDestination = Read-Host "Enter a PC asset, hostname, or custom path"
|
||||
# Parse input for asset tag, hostname, then full path
|
||||
if ($BackupDestination -match "^[1-9]{5}$") {
|
||||
$BackupDestination = Get-AssetConversion $BackupDestination
|
||||
}
|
||||
# Will attempt to convert to Hostname if possible, doesn't change if not
|
||||
$BackupDestination = Get-Hostname $BackupDestination
|
||||
# Treat as hostname and see if it's reachable
|
||||
if (Test-Connection -ComputerName $BackupDestination -Count 1) {
|
||||
# If so, get the filesystem path
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
.SYNOPSIS
|
||||
Backs up a user profile to a specified filepath.
|
||||
.DESCRIPTION
|
||||
Takes a input of hostname and user and will make a copy of the user profile
|
||||
Takes a input of a user profile filepath, will make a copy of the user profile
|
||||
and the Microsoft Roaming Folder and back it up to a specified filepath.
|
||||
#>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue