diff --git a/Private/UserProfileBackup.ps1 b/Private/UserProfileBackup.ps1 index 639a747..19aad7e 100644 --- a/Private/UserProfileBackup.ps1 +++ b/Private/UserProfileBackup.ps1 @@ -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)" @@ -332,15 +325,4 @@ } } #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 - } -} - + }#End Function \ No newline at end of file