Complete novice on PS here. however i have a script that i wrote to pull certain files off of windows 7 and windows 10 laptops. The script works perfectly on windows 7 but not on windows 10. The code i have is below:
$date = Get-Date -UFormat %m%d%Y
#Gets and assigns the drive letter for the backup destination, located on the USB drive.
$winpe = Get-WmiObject win32_logicaldisk -filter "VolumeName = 'WINPE'"
$servicetag = Get-WmiObject win32_bios
$tag = $servicetag.serialnumber
$a = $winpe.DeviceID
$dest = "$a\Backups\$tag-$date"
#Gets and assigns the drive letter for the Hard Drive.
$hdd = Get-WmiObject win32_logicaldisk -Filter "VolumeName = 'OSDISK'"
$d = $hdd.DeviceID
#If backup for current date has been created, stop script. Else, backup files.
if (Test-Path $dest){
Write-Host "Backup already completed."
break
} else {
cd $d
I get an error on windows 10 that says "
cd : Cannot process argument because the value of argument "path" is null. Change the value of argument "path" to a non-null value.
At line:2 char:3
+ cd $d
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Location], PSArgumentNullException
+ FullyQualifiedErrorId : ArgumentNull,Microsoft.PowerShell.Commands.SetLocationCommand
I'm assuming that it has something to do with changing the directory but it works fine on windows 7. any help would be greatly appreciated. t