This topic contains 6 replies, has 4 voices, and was last updated by
August 20, 2018 at 4:41 pm #109049
Hello,Below is my logon script on PS command.
The code works very well.
But! All users have shared folders at Windows logon (with rights and no access rights).
How can I view only users' shared folders with access to the directory.
I am sorry for my bad english.
$ndriveobj = New-Object -Com wscript.network$ndriveobj.RemoveNetworkDrive("G:", $true,)
$ndriveobj.MapNetworkDrive("H:", "\TRIESTE\Secteur accompagnement", $true)
$ndriveobj.RemoveNetworkDrive("I:", $true, $true)$ndriveobj.MapNetworkDrive("I:", "\TRIESTE\PARAMEDICAUX", $true)
$ndriveobj.RemoveNetworkDrive("J:", $true, $true)$ndriveobj.MapNetworkDrive("J:", "\TRIESTE\SECRETARIAT", $true)
$ndriveobj.RemoveNetworkDrive("K:", $true, $true)$ndriveobj.MapNetworkDrive("K:", "\TRIESTE\Secrétariat Direction", $true)
$ndriveobj.RemoveNetworkDrive("M:", $true, $true)$ndriveobj.MapNetworkDrive("M:", "\TRIESTE\LIBRE2", $true)
I am in "Windows PowerShell"
August 20, 2018 at 4:44 pm #109054ParticipantPoints: 1,564Rank: Community Hero
You have to use gist (via github) or the 'pre' tags for posting script in the forum. Please edit and format it properly for others to understand properly.
August 20, 2018 at 4:56 pm #109058ParticipantPoints: 632Rank: Major Contributor
If only certain users have access, we'll assume by a Active Directory Group (or even better a OU), why not assign the policy only to those users? You need to be more clear on what your issue is.
August 20, 2018 at 6:16 pm #109069
The code works perfectly, but it connects all network drives to all users. Is it possible that it connects only shared folders with read or edit permission.
August 20, 2018 at 6:49 pm #109072
August 20, 2018 at 7:09 pm #109081
Can you help me understand better?
August 20, 2018 at 7:24 pm #109082ParticipantPoints: 632Rank: Major Contributor
Basically, there are a better methods to do what you are attempting to do with a script. If you look at the link that @stephenmbell posted, it shows you map drives using preferences. Based on what you've posted, it sounds like you want the code to determine if a drive mapping should occur, however, we are saying that you should be doing that before the script runs by defining a mapping by group in GPO preferences or assigning the policy to only users that should run the script. In summary, this seems like something that you should correct with Active Directory setup, not Powershell code.
The topic ‘Logon script PS’ is closed to new replies.