Cleaned up warnings in UserProfileBackup
This commit is contained in:
parent
b02b46baa3
commit
e41c8897dd
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
)
|
||||
|
||||
if($Computer -eq $null){
|
||||
if($null -eq $Computer){
|
||||
$Computer = Read-Host -Prompt 'Enter computer name: '
|
||||
}
|
||||
$ConfirmUser = $null
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
$lastUser = Invoke-Command -ComputerName $Computer -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {
|
||||
Get-ChildItem -Path C:\Users -Directory -Force -Exclude Public,Default,'Default User','All Users' |
|
||||
Sort-Object -Property LastWriteTime -Descending | Select-Object -First 3 -ExpandProperty Name }
|
||||
if($lastUser -eq $null){
|
||||
if($null -eq $lastUser){
|
||||
Write-warning "PC unreachable or no profiles to back up"
|
||||
return
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
Write-Host "Latest Users: $lastUser"
|
||||
|
||||
#Asks user to pick which profile to backup
|
||||
while( $ConfirmUser -eq $null ){
|
||||
while($null -eq $ConfirmUser){
|
||||
$User = Read-Host -Prompt 'Choose user to backup'
|
||||
|
||||
if( -not ( Test-Path -Path "\\$Computer\c$\Users\$User" -PathType Container ) ){
|
||||
|
|
@ -66,13 +66,6 @@
|
|||
break
|
||||
}
|
||||
}
|
||||
<#
|
||||
Write-Host "Scanning user profile..."
|
||||
$profileSize = scan-dir "\\$Computer\c$\Users\$User"
|
||||
|
||||
$sizeout = "{1} profile is {0:n3}GB" -f $profileSize,$user
|
||||
Write-Host $sizeout
|
||||
#>
|
||||
|
||||
$ConfirmUser = Read-Host -Prompt "Copy profile? (y/n) or Restore profile (r)"
|
||||
|
||||
|
|
@ -333,14 +326,3 @@
|
|||
}
|
||||
#endregion
|
||||
}#End Function
|
||||
|
||||
#Helper Function
|
||||
function scan-dir($Path) {
|
||||
if ( (Test-Path $Path) -and (Get-Item $Path).PSIsContainer ){
|
||||
$DirectorySize = (Get-ChildItem -Path $path -File -Recurse -Force -ErrorAction SilentlyContinue |
|
||||
Measure-Object -Property Length -Sum).Sum / 1GB
|
||||
|
||||
Return $DirectorySize
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue