Files
Sandbox/HomeDriveNoSign.ps1
T
Zack Meier 03dba08135 sync
2026-04-15 15:42:41 -05:00

25 lines
590 B
PowerShell

$Filter = "(samaccountname=$env:username)"
$RootOU = "dc=nd,dc=gov"
Write-Warning $Filter
$Searcher = New-Object DirectoryServices.DirectorySearcher
$Searcher.Filter = $Filter
$result=$Searcher.FindAll()
$homedir = $result.properties.homedirectory
$homedrive = $result.properties.homedrive
$ScriptPath = $result.properties.scriptpath
If($ScriptPath)
{
$LoginScript = "\\nd.gov\netlogon\$ScriptPath"
Start-Process "cmd.exe" "/c $loginscript" #<< run loginscript
}
If($homedrive)
{
New-PSDrive -Name $homedrive.TrimEnd(':') -PSProvider FileSystem -Root $homedir -Persist
}