@@ -108,12 +108,17 @@ Get-WmiObject win32_StartupCommand -ComputerName $name | select caption,descrip
108
108
$localusers = Get-WmiObject win32_UserAccount - ComputerName $name - Filter " LocalAccount='$True '" | select Name, SID, PasswordExpires, Disabled, Lockout | ConvertTo-html - Body " <H2> Local Users </H2>" >> " $filepath \$name .html"
109
109
110
110
# ##local user group membershipe
111
- $adsi = [ADSI ]" WinNT://$env: COMPUTERNAME "
112
- $adsi.Children | where {$_.SchemaClassName -eq ' user' } | Foreach-Object {
111
+ # ##Check if machine is a domain controller first to prevent large unreadable table
112
+ Import-Module servermanager
113
+ $Domaincontroller = get-windowsfeature | where {$_.Name -eq " ADDS-Domain-Controller" -and $_.installed -eq $true }
114
+ if ($Domaincontroller -eq $null ){
115
+ $adsi = [ADSI ]" WinNT://$env: COMPUTERNAME "
116
+ $adsi.Children | where {$_.SchemaClassName -eq ' user' } | Foreach-Object {
113
117
$groups = $_.Groups () | Foreach-Object {$_.GetType ().InvokeMember(" Name" , ' GetProperty' , $null , $_ , $null )}
114
118
$_ | Select-Object @ {n = ' UserName' ;e = {$_.Name }}, @ {n = ' Groups' ;e = {$groups -join ' ;' }}
115
- } | ConvertTo-html - Body " <H2> Local User Group Memberships </H2>" >> " $filepath \$name .html"
116
-
119
+ } | ConvertTo-html - Body " <H2> Local User Group Memberships </H2>" >> " $filepath \$name .html"
120
+ }
121
+ Else {}
117
122
# MotherBoard: Win32_BaseBoard # You can Also select Tag,Weight,Width
118
123
Get-WmiObject - ComputerName $name Win32_BaseBoard | Select Name, Manufacturer, Product, SerialNumber, Status | ConvertTo-html - Body " <H2> MotherBoard Information</H2>" >> " $filepath \$name .html"
119
124
@@ -260,5 +265,4 @@ $schtasks | ConvertTo-Html -Body "<H2>Scheduled Tasks</H2>" >> "$filepath\$name.
260
265
261
266
# ###Send Email if required
262
267
If ($sendemail -eq $true ){
263
- Send-MailMessage - To $to - Subject $subject - From $from $subject - SmtpServer $smtp - Priority " High" - BodyAsHtml - Attachments " $filepath \$name .html"
264
- }
268
+ Send-MailMessage - To $to - Subject $subject - From $from $subject - SmtpServer $smtp - Priority " High" - BodyAsHtml - Attachments " $filepath \$name .html" }
0 commit comments