Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Need to pull login script name and place in file path to run batch file

$
0
0

Working on a powershell script for our conference room laptops. The users will log in with a generic username and password and then run this powershell script that will ask for username and password that will give them access to networked drives if needed.

Below is the current setup

$Credential = Get-Credential $Username = $Credential.UserName $Script = Get-ADUser -Identity $Credential.UserName -Properties * | select ScriptPath $Path = "\servernameNETLOGON" $scriptpath = $Path + "" + $Script $scriptpath ii "\servernameUsers$USERNAMEMy Documents" 

the initial part works great as far as pulling the credentials can giving them access to there networked “my documents” folder, however, when trying to pull the rest of drives in im getting the following output.

\adsvrNETLOGON@{ScriptPath=LOGON_IS.BAT} 

so the $path request is coming through fine, but when i try to add the $Script to the end of the network address, it reads it as above.

Any thoughts?

Edit:

Figured id post what was written to share,

$Credential = Get-Credential $Username = $Credential.UserName $Script = (Get-ADUser -Identity $Credential.UserName -Properties ScriptPath).ScriptPath $Path = "\ServerNameNETLOGON" $scriptpath = $Path + "" + $Script & $scriptpath ii "\ServerNameUsers$USERNAMEMy Documents" 

submitted by /u/SCATesteR
[link] [comments]

The post Need to pull login script name and place in file path to run batch file appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles