Windows 7 Create/verify/delete libraries by script?

jbrickman0000

New Member
Joined
Nov 25, 2009
Messages
4
Is there a way to script the verification, creation, and deletion of Windows 7 libraries, using any script engine which will run as a login script? For 7 desktops in AD, I would much rather use libraries than mapped drives, if possible.

J.E.B.
 

Solution
To script the verification, creation, and deletion of Windows 7 libraries as a login script for desktops in Active Directory, you can use a PowerShell script. PowerShell is a powerful scripting language for Windows that can handle tasks like managing Windows libraries efficiently. Here's how you can achieve this using a PowerShell script:

Script to Manage Windows 7 Libraries​

1. Verify Library Existence:​

Code:
# Check if the library exists $libraryName = "Documents" # Change this to the library name you want to check if (-not (Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Libraries\$libraryName")) { Write-Host "$libraryName library does not exist." } else { Write-Host "$libraryName library...
To script the verification, creation, and deletion of Windows 7 libraries as a login script for desktops in Active Directory, you can use a PowerShell script. PowerShell is a powerful scripting language for Windows that can handle tasks like managing Windows libraries efficiently. Here's how you can achieve this using a PowerShell script:

Script to Manage Windows 7 Libraries​

1. Verify Library Existence:​

Code:
# Check if the library exists $libraryName = "Documents" # Change this to the library name you want to check if (-not (Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Libraries\$libraryName")) { Write-Host "$libraryName library does not exist." } else { Write-Host "$libraryName library exists." }

2. Create a Library:​

Code:
# Create a new library $libraryPath = "C:\Path\To\Library" # Path to the folder you want to include in the library $libraryName = "Documents" # Library name New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Libraries\$libraryName" -Force | Out-Null New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Libraries\$libraryName" -Name "LibraryDescription" -Value $libraryPath -PropertyType String -Force | Out-Null

3. Delete a Library:​

Code:
# Delete an existing library $libraryName = "Documents" # Library name to delete Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Libraries\$libraryName" -Force

Running as a Login Script​

To run this script as a login script for the Windows 7 desktops in Active Directory, you can add the script to a Group Policy Object (GPO). Follow these steps:
  1. Edit a Group Policy Object that applies to the users logging in.
  2. Go to "User Configuration" > "Policies" > "Windows Settings" > "Scripts (Logon/Logoff)".
  3. Select "Logon" and click on "Add".
  4. Browse to the location where you have saved the PowerShell script and add it.
  5. Click "OK" to save the settings. Make sure that the computers have PowerShell execution policy set to allow the script to run. You can set it to RemoteSigned by running Set-ExecutionPolicy RemoteSigned. This approach allows you to manage Windows 7 libraries dynamically during user logon, providing a more flexible and efficient way to organize and access files than mapped drives.
 

Solution
Back
Top