diff options
author | Pawel Spychalski (DzikuVx) <pspychalski@gmail.com> | 2018-08-15 11:13:16 +0300 |
---|---|---|
committer | Pawel Spychalski (DzikuVx) <pspychalski@gmail.com> | 2018-08-15 11:13:16 +0300 |
commit | 79b76cbcec3027bf8ce984626900a92daedf6833 (patch) | |
tree | 482887a92d2e19954d099082c0eeea42aa3d9114 /post_install_cleanup.ps1 | |
parent | d8c7a9d4ec6eb2a6ac21223b3fef7db810c47333 (diff) |
PowerShell cleaning script by James Cherrill
Diffstat (limited to 'post_install_cleanup.ps1')
-rwxr-xr-x | post_install_cleanup.ps1 | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/post_install_cleanup.ps1 b/post_install_cleanup.ps1 new file mode 100755 index 00000000..3832e2bf --- /dev/null +++ b/post_install_cleanup.ps1 @@ -0,0 +1,31 @@ +### this will remove the folders from %appdatalocal% for each user account on a given computer and then recreate the inav-configurator folder and place a text file in that folder. The script checks for this file and if it exsists will simply exit. +## because this checks each and every user on the windows machine ps will kick out some errors for any user that it doesnt have permission to access there local app data folder. these can be ignored. + + +#check for file +$txtfilepath = "C:\Users\$($_.Name)\AppData\Local\inav-configurator\check.txt" + +$testpath = test-path $txtfilepath + +if ($testpath -eq $true){ + $append = "Terminated at time xxxxx" + $append | out-file $txtfilepath -append -force + break +} +else{ + #continue script + # Get users +$users = Get-ChildItem -Path "C:\Users" + +# Loop through users and delete the folder +$users | foreach-Object { + Remove-Item -Recurse -Path "C:\Users\$($_.Name)\AppData\Local\inav-configurator" -Force + +} +} + #create new inav-configurator folder + New-Item -Path "C:\Users\$($_.Name)\AppData\Local\" -name "inav-configurator" -ItemType "directory" + # add text file to check for + New-Item -Path "C:\Users\$($_.Name)\AppData\Local\inav-configurator" -name "check.txt" -ItemType "file" -Value "config cleared" + break +
\ No newline at end of file |