This has been bugging the h ell out of me, I need to map a drive, or run a program that can only be run by the logged in user, and if I map the drive from session 0 the user does not see it.
The below script works but wish Pulseway had better run as user features built in. This script will map a drive letter for the logged in user, change server and share name to your info. you can change the /TR "any commoand you want to run as the user"
This has been bugging the h ell out of me, I need to map a drive, or run a program that can only be run by the logged in user, and if I map the drive from session 0 the user does not see it.
The below script works but wish Pulseway had better run as user features built in. This script will map a drive letter for the logged in user, change server and share name to your info. you can change the /TR "any commoand you want to run as the user"
$Taskname = "MapX"
$lastlogon = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser")
SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $Taskname /RU $lastlogon /TR "net use x: \\<server-name>\<share-name> /persistent:yes" /F
start-sleep -s 4
schtasks /Run /TN $Taskname
start-sleep -s 1
schtasks /delete /tn $Taskname