-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGet-Smb1status.ps1
61 lines (36 loc) · 1.25 KB
/
Get-Smb1status.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
<#
installstate posible values:
Enabled (1)
Disabled (2)
Absent (3)
Unknown (4)
#>
function Get-Smb1status{
begin{
Add-Type -Language CSharp @"
public class smb_1{
public string SMB1Protocol ;
public string SMB1Protocol_Client;
public string SMB1Protocol_Server;
public string SMB1Protocol_Deprecation;
}
"@
}
process{
$obj=New-Object -TypeName smb_1
$smb=Get-WmiObject -query "select * from win32_optionalfeature where name like '%smb1%' "|select name,installstate
$smb.foreach{
$name=($_.name).replace('-','_').trim()
$state=$_.installstate
switch ($state)
{
1 {$state='Enabled'; Break}
2 {$state="Disabled" ; Break }
3 {$state="Absent" ; Break }
4 {$state="Unknown" ; Break }
}#end switch
$obj.$name=$state
}#end foreach smb
Write-Output $obj
}
}#end func