我了解join域的计算机在AD中拥有计算机帐户,并且这些帐户的密码过期(显然每30天默认),并且这些密码会自动更改,无需用户干预。
鉴于在恢复已join域的虚拟机的快照时,这已知会导致问题,是否可以查询join域的计算机或AD以确定计算机帐户密码何时计划更改?
有可能为此查询域名,下面的脚本会告诉你什么时候一台特定的机器的域名密码是上次重置的。
'Replace "yourdom.com" with your domain name. DomainName = "yourdom.com" querymachine = UCase(inputbox("Enter full machine name")) lngBias = 2 '****************Setup Log file****************************************************** Set fso = CreateObject("Scripting.FileSystemObject") 'The 8 in this line will append to an existing file, replace with a 2 to override set txtStream = fso.OpenTextFile("System.txt", 8, True) txtStream.WriteLine "Ran on " & Date & " *******************************" '****************Setup ADSI connection and populate ADSI Collection****************** Set objADOconnADSI = CreateObject("ADODB.Connection") objADOconnADSI.Open "Provider=ADsDSOObject;" Set objCommandADSI = CreateObject("ADODB.Command") objCommandADSI.ActiveConnection = objADOconnADSI 'there is a 1000 object default if these next 2 lines are omited. objCommandADSI.Properties("Size Limit")= 100000 objCommandADSI.Properties("Page Size")= 100000 objCommandADSI.Properties("Sort on") = "sAMAccountName" objCommandADSI.CommandText = "<LDAP://" & DomainName & ">;(objectClass=computer);sAMAccountName,pwdLastSet,name,distinguishedname,operatingSystem;subtree" Set objRSADSI = objCommandADSI.Execute 'Loop through record set and compare machine name************************************* do while NOT objRSADSI.EOF if not isnull(objRSADSI.Fields("distinguishedname")) and objRSADSI.Fields("distinguishedname") <> "" then objDate = objRSADSI.Fields("PwdLastSet") 'Go to function to make sense of the PwdLastSet value from AD for the machine account. dtmPwdLastSet = Integer8Date(objDate, lngBias) 'calculate the current age of the password. DiffADate = DateDiff("d", dtmPwdLastSet, Now) 'Is the machine the one we're looking for? if UCase(objRSADSI.Fields("name")) = querymachine then txtStream.WriteLine objRSADSI.Fields("name") & ";" & dtmPwdLastSet & ";" & DiffADate & ";" & objRSADSI.Fields("operatingSystem") wscript.echo objRSADSI.Fields("name") & ", Last set: " & dtmPwdLastSet & ", Days since last change: " & DiffADate end if end if objRSADSI.MoveNext loop wscript.echo "Done!" Function Integer8Date(objDate, lngBias) ' Function to convert Integer8 (64-bit) value to a date, adjusted for ' local time zone bias. Dim lngAdjust, lngDate, lngHigh, lngLow lngAdjust = lngBias lngHigh = objDate.HighPart lngLow = objdate.LowPart ' Account for bug in IADslargeInteger property methods. If lngLow < 0 Then lngHigh = lngHigh + 1 End If If (lngHigh = 0) And (lngLow = 0) Then lngAdjust = 0 End If lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _ + lngLow) / 600000000 - lngAdjust) / 1440 Integer8Date = CDate(lngDate) End Function
(我很想赞扬上面的剧本,但是这个剧本已经被人为地交换了,并且以各种各样的方式进行了修改,我不知道它是从哪里来的)
保存为MachinePasswordDate.vbs,双击Windows中的文件应popup一个框,你可以把一个机器名,然后应该查询域,并告诉你什么时候该机器的密码是最后一次更改。
如果您定期恢复虚拟机快照,则可能需要先查看这些计算机上的安全策略,然后再保存映像。 假设您的域GPO不会覆盖它,您可以很容易地将机器密码重置间隔更改为999天,并且您的安全策略允许这样的事情:
单击开始,单击运行,键入Gpedit.msc,然后按ENTER键。
展开本地计算机策略,计算机configuration,展开Windows设置,展开安全设置,展开本地策略,然后展开安全选项。
configuration以下设置:
域成员:禁用机器帐户密码更改(启用)
域名成员:最大机器账号密码年龄(999天)
域控制器:拒绝机器帐户密码更改(启用)
在DC或具有RSAT的任何计算机上,可以运行dsquery computer -name ComputerName -stalepwd x
ComputerName是您要检查的计算机的名称
x是密码上次设置以来的天数。
如果密码自x天以来没有设置,它将返回计算机的名称和容器。 如果密码在最近x天内被设置,它将不会返回任何内容。