-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSet_NETBIOS_Enable_Disable.ps1
77 lines (51 loc) · 2.53 KB
/
Set_NETBIOS_Enable_Disable.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<#
.SYNOPSIS
Gets COMPUTER Set NetBIOS STATUS !!! FUN STUFF
.EXAMPLE
'one', 'two', 'three' Set_Netbios.ps1
.EXAMPLE
Set_Netbio.ps1 -computername localhost
.EXAMPLE
Set_Netbio.ps1 -computeername one, two, three
.EXAMPLE
get-content <ServerList.txt> or <ServerList.csv> | Set_Netbio.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\Set_netbios_errors.log'
)
begin{
$host.UI.RawUI.WindowTitle = "Set Netbios"
$grab = Read-Host "Please enter 1 to Enable or 2 for Disable."
}
process{
foreach ($computer in $computername) {
Write-Verbose "about to query $computer"
try {
$serverislive =$true
$who = Get-WMIObject Win32_ComputerSystem -computername $computer| Select-Object -ExpandProperty name
} catch {
$serverislive = $false
Write-Verbose "$computer failed wrting to $errorlogpath "
Write-Verbose " Error was $MyErr"
$computer | Out-File $errorlogpath -append
}
$IgotInput= $grab
$nic = Get-WmiObject Win32_NetworkAdapterConfiguration -computername $computer -filter "ipenabled = 'true'" | Select-Object -ExcludeProperty *
$nicview = $nic.SetTcpipNetbios($IgotInput) | select "-"
$who = Get-WMIObject Win32_ComputerSystem -computername $computer| Select-Object -ExpandProperty name
$netBT =Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername $computer | Where {$_.IPEnabled -eq "true"} | select TcpipNetbiosOptions
$Domain = Get-WmiObject -Class Win32_ComputerSystem -computername $computer
$props = @{'computername' = $computer;
'Netbios Status' = $netBT.TcpipNetbiosOptions;
'DOMAIN'= $Domain.domain;
'ServerName'=$who;}
$obj = New-Object -TypeName PSObject -Property $props
Write-output $obj
}
}
end{}