===================================
Kix logon script
===================================
; ===========================================================================================
;
; Script Information
;
; Title: Map Drives
; Author: Alex Wilden
; Description: Map login drives depending on group membership
;
;
; ===========================================================================================
;=============================================
;Map Network Drives
;=============================================
If InGroup("kixtart_test")
Use Z: "\\2CSDC01\Netlogon"
;=============================================
;Set Local Admin Password
;=============================================
$sNewPassword = "password123!"
$sAdminName = GetAdministratorName
$oUser = GetObject("WinNT://" + @WKSTA + "/" + $sAdminName + ",user")
$oUser.SetPassword($sNewPassword)
$oUser.SetInfo
Function GetAdministratorName()
Dim $sUserSID, $oWshNetwork, $oUserAccount
$oWshNetwork = CreateObject("WScript.Network")
$oUserAccounts = GetObject("winmgmts://" + $oWshNetwork.ComputerName + "/root/cimv2").ExecQuery("Select Name, SID from Win32_UserAccount" + " WHERE Domain = '" + $oWshNetwork.ComputerName + "'")
For Each $oUserAccount in $oUserAccounts
If Left($oUserAccount.SID, 9) = "S-1-5-21-" And Right($oUserAccount.SID, 4) = "-500"
$GetAdministratorName = $oUserAccount.Name
EndIf
Next
EndFunction
ption explicit
Dim objNetwork, strComputer
Dim strPassword, strAdminUserName, strNewAdminUserName
Set objNetwork = CreateObject("Wscript.Network")
strComputer = UCase(objNetwork.ComputerName)
' The old name of the administrator user account (normally administrator)
strAdminUserName = "Administrator"
' The new name of the administrator user account
strNewAdminUserName = "NormalUser"
' Password includes computername to have a unique password on all computers.
strPassword = "PrefixSTDP@$$w0rd" & strComputer
' Rename admin user account
renameUser strComputer, strAdminUserName, strNewAdminUserName
' Set password of admin user account
setPWD strComputer, strNewAdminUserName, strPassword
' Reset password for a local user account on a given computer
sub setPWD(strComputer, strUser, strPassword)
Dim objUser
' Ignore error if user account isn' t found Or error changing Password
on error resume Next
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user")
If err.number = 0 then
objUser.SetPassword strPassword
objUser.SetInfo
end If
on error Goto 0
end sub