PowerShell: Locking Drive Content

Posted Leave a commentPosted in PowerShell

This will not hide drive letters but prohibit access to drive content. You need administrative privileges to set this setting. function Hide-DriveContent { param($DriveLetter) $key = @{ Path = ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer’ Name = ‘NoViewOnDrive’ } if ($DriveLetter -eq $null) { Remove-ItemProperty @key } else { $mask = 0 $DriveLetter | ForEach-Object { $_.toUpper()[0] } | Sort-Object […]

PowerShell: Hiding Drive Letters

Posted Leave a commentPosted in PowerShell

Sometimes you may want to hide drive letters in Windows Explorer from users. There’s a Registry key that can do this for you. It takes a bit mask where each drive has a bit. When the bit is set, the drive is hidden. function Hide-Drive { param($DriveLetter) $key = @{ Path = ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer’ Name = […]

PowerShell: Copying Files in the Background

Posted Leave a commentPosted in PowerShell

The main advantage of BITS is that it can copy things silently in the background, and it is resilient to interruptions such as reboots. After a reboot, BITS will continue the copy process, so this can be a good starting point to create a robust backup mechanism. Import-Module BitsTransfer # adjust source and destination to […]