1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| ' ********************************************************************
' Script to MAP users disks for ALL CHACAL iX ENVIRONMENTS and merge
' putty registry and rsa_key at logon
' ********************************************************************
Option Explicit
Dim domainName,userName,ADSPath,grouplistD,GrpName,groupName
Dim objUser,objGroup,WshNetwork,wshShell,strComputerName
' *****************************************************
' GET %USERNAME% to initialize username variable
' *****************************************************
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set wshShell = CreateObject("WScript.Shell")
'WScript.Echo "Computer Name: " & strComputerName
GrpName= Array("GRPINFO","GRPCOMDPC","GRPGSBEXPORT","GRPGXF","GRPSUPCHAIN","GRPACHATS","GRPGESTION")
domainName = "mydomain.com"
userName = WshNetwork.UserName
strComputerName = WshNetwork.ComputerName
Select Case strComputerName
Case "V2K12RDS14" 'DEV
WSHShell.Run "cmd /c \\DC01\NETLOGON\PuttyDEV.cmd"
Case "V2K12RDS11" 'PRD
WSHShell.Run "cmd /c \\DC01\NETLOGON\PuttyDIAPPROD.cmd"
Case "V2K12RDS12" 'PRD
WSHShell.Run "cmd /c \\DC01\NETLOGON\PuttyDIAPPROD.cmd"
Case "V2K12RDS13" 'PRD
WSHShell.Run "cmd /c \\DC01\NETLOGON\PuttyDIAPPROD.cmd"
Case "V2K12RDS8" 'REC
WSHShell.Run "cmd /c \\DC01\NETLOGON\PuttyDIAP5.cmd"
Case "V2K12RDS15" 'REC-TMP
WSHShell.Run "cmd /c \\DC01\NETLOGON\PuttyDIAP7.cmd"
Case Else
End Select
' WSHShell.Run " net Use Q: /Delete"
Wshshell.run "net use Q: \\V2K12NAS\Chacal_Data$"
' WSHShell.Run "net Use V: /Delete"
Wshshell.run "net use V: \\VLNXDIAP1\CHACAL_PDF"
For each groupName in GrpName
If IsMember(domainName,userName,groupName) Then
' WSHShell.Run "net Use U: /Delete"
wshshell.run "net use U: \\NASGFX\USERS"
Else
End If
Next
If IsMember(domainName,userName,"GRPPARIS") Then
' WSHShell.Run "net Use U: /Delete"
wshshell.run "net use U: \\G2K16PAR01\USERS"
Else
End If
If IsMember(domainName,userName,"GRPPRODDPC") Then
' WSHShell.Run "net Use U: /Delete"
wshshell.run "net use U: \\V2K12MTL01\USERS"
Else
End If
If IsMember(domainName,userName,"GRP_ESPACE_COMMERCIAL_CHANTIER") Then
' WSHShell.Run "net Use T: /Delete"
wshshell.run "net use T: \\NASGFX\AgencesDPCSav"
Else
End If
WScript.quit
' ***********************************************************************
'This function checks if the given AD user is member of the given group.
' ***********************************************************************
Function IsMember(domainName,userName,groupName)
Set groupListD = CreateObject("Scripting.Dictionary")
groupListD.CompareMode = 1
ADSPath = domainName & "/" & userName
Set objUser = GetObject("WinNT://" & ADSPath & ",user")
For Each objGroup in objUser.Groups
groupListD.Add objGroup.Name, "-"
Next
IsMember = CBool(groupListD.Exists(groupName))
End Function |
Partager