forked from officecigar/windows_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheck_NETBIOS_Servers.ps1
62 lines (42 loc) · 1.63 KB
/
Check_NETBIOS_Servers.ps1
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
<#
.SYNOPSIS
Gets COMPUTER BIOS STATUS !!! FUN STUFF
.EXAMPLE
'one', 'two', 'three' Netwmi.ps1
.EXAMPLE
Netwmi.ps1 -computername localhost
.EXAMPLE
Netwmi.ps1 -computeername one, two, three
.EXAMPLE
get-content <ServerList.txt> or <ServerList.csv> | Netwmi.ps1
.PARAMETER computername
one or more computername, or IP address... peace to America!
#>
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true,ValuefromPipeline=$true)]
[string []]$computername,
[string]$errorlogpath ='c:\temp\errors.log'
)
begin{$host.UI.RawUI.WindowTitle = "Check Netbios"
}
process{
foreach ($computer in $computername) {
Write-Verbose "about to query $computer"
try {
$who = Get-WMIObject Win32_ComputerSystem -computername $computer| Select-Object -ExpandProperty name -ErrorAction
}catch {
$computer |Out-File $errorlogpath -append
}
$Domain = Get-WmiObject -Class Win32_ComputerSystem -computername $computer
$netBT = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername $computer | Where {$_.IPEnabled -eq "true"} | select TcpipNetbiosOptions
$props = @{'computername' = $computer
'Netbios Status' = if ($netBT.TcpipNetbiosOptions -eq "2") {'DISABLED' } Else {'ENABLED'} ;
'Server Name' = $who;
'DOMAIN'= $Domain.domain;}
$obj = New-Object -TypeName PSObject -Property $props
Write-Output $obj
}
}
End{
}