forked from jorgenavarromanzano/Microsoft-PowerShell-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript_Doc_Windows_Server_20XX
More file actions
2990 lines (2723 loc) · 124 KB
/
Script_Doc_Windows_Server_20XX
File metadata and controls
2990 lines (2723 loc) · 124 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#JORGE NAVARRO MANZANO Script Doc Windows Server 20XX, needs .net 2.0 and powershell 2.0(check version with get-host)
#https://linkedin.com/in/jorgenavarromanzano
#more scripts here https://github.com/jorgenavarromanzano
#it creates two files nodename.html (in html format) and nodename.txt (tikiwiki format http://tiki.org)
#lot of info, like hw, devices, services, programs, updates, env, app infos, nlb, cluster, iis, ad, dns, dhcp, etc etc.
#used functions of productkeys for windows and sql from JAKOB BINDSLET and Chrissy LeMaire
#only compatible with english/spanish windows servers(you can run it in other languages but some string filters wont work)
#see html outputs examples in the zip file
#Instructions:
#run as an administrator user powershell and copy all code
#can also be runned from an automation tool(please be sure your automation tool works fine, dont reboot the server after execution etc)
#user with local system the output folder will be C:\Windows\system32\config\systemprofile
#also you can uncomment this folder so the output will be copied there
#make sure to add everyone permissions change share/write ntfs temporarily to the folder
#if local system user used as it doesnt have network permissions
#it depends of the automation tool but maybe you need to enable remote execution of .ps files set-executionpolicy unrestricted
#$outputsharefolder = "\\192.168.1.1\temp"
#numoutperformance number of performance statistics lines, default 10, can be infinite/99999 to generate a big performance report
$numoutperformance = 10
#if you want the script to copy the .txt and .html files to the directory of your pc from where you connect by rdp to the servers, just change the next folder:
#(need rdp drive redirection enabled)
#example: $locationdir = "\\tsclient\C\users\che\desktop\"
$locationdir = "\\tsclient\C\users\che\desktop\"
$locationexist = get-childitem $locationdir -ErrorAction silentlycontinue
$error.clear()
if($locationexist -ne $null)
{
set-location $locationdir
}
#INFO: #always #?optional only if exists
#Server Info
#ProductKeys
#Hardware
#Devices
#?Remote Console requieres hponcfg
#Performance
#ENV
#Eventlog
#Startup Programs
#Net
#ipconfig
#?nicteaming
#?MTU -> w2008 and earlier
#routes
#hosts file
#ntpclient
#other
#netstat
#?NLB
#?Cluster
#Shares-Mapped Drives
#ODBC
#?Roles-Features
#Programs
#Updates
#?IIS-FTP-SMTP
#?HyperV
#?RDS
#?PrintServer
#?Terminal Server
#?NPS
#?RAS
#Services
#Info Services
#Local Users/Groups/Policies
#?SQL Server -> user need to has access/permissions to SQL and pssnapin SqlServerCmdletSnapin100
#?DNS Server
#?DHCP Server
#?Printers
#?Active Directory
#Stats
#DCS
#Sites
#Trusts
#Authorized DHCP Servers
#DCDIAG
#Tasks
#Review
#eventviewer export app/system to $home\desktop
#Server Description add manually
#Service Check add manually
#Notes add manually
#changes (only after 202004)
#changes20200424
#add nic teaming
#add w2019
#add pending updates
#changes20200428
#added info allservices
#changed tiki first sections
#changes20200512
#added support automation tools output in $home of the user (usually local system is in C:\Windows\system32\config\systemprofile)
#changed copy to rdp folder
#added option to copy output to a shared folder
#changes20200513
#modified updates section (some errors because of wrong values in installedon value)
#notranscript if run from automation tool (because it fails with hp server automation)
#changes20200520
#added variable $numoutperformance for generating big performance report of servers
#todo
#add ntfs blocksize Get-WmiObject -Class Win32_Volume | Select-Object caption,Label, BlockSize | Format-Table -AutoSize
if(test-path $env:userprofile\desktop)
{
cd $env:userprofile\desktop
}elseif(test-path $env:userprofile\escritorio)
{
cd $env:userprofile\escritorio
}else{
cd $home
$transcript = 0
}
if($env:userprofile -eq "C:\Documents and Settings\Default User")
{
$transcript = 0
}
if($transcript -ne 0)
{
start-transcript $pwd\docwindows_log.txt
}
$revision = @()
$functions = $functions+" Functions: "
$powershellv = (get-host).version.major
$fecha = get-date
$name = hostname
$fichero = New-Object System.IO.StreamWriter $pwd\$name".txt"
$ficherohtml = New-Object System.IO.StreamWriter $pwd\$name".html"
$fichero.writeline("{DIV(float=>left,bg=>lightyellow,width=>40%)}")
$fichero.writeline("{maketoc}{DIV}")
$fichero.writeline("--------------------")
$fichero.writeline("!#Server Description")
$fichero.writeline("")
$fichero.writeline("")
$fichero.writeline("--------------------")
$fichero.writeline("!#Service Check")
$fichero.writeline("")
$fichero.writeline("")
$fichero.writeline("--------------------")
$fichero.writeline("!#Notes")
$fichero.writeline("")
$fichero.writeline("")
$fichero.writeline("!#Server Info")
$ficherohtml.writeline("<A name=Server Info></A>")
$ficherohtml.writeline("<H3>Server Info</H3>")
$domain = (get-wmiobject -class WIN32_ComputerSystem -property Domain).Domain
$fichero.writeline("Server:"+$domain+"\"+$name)
$ficherohtml.writeline("Server:"+$domain+"\"+$name+"<br>")
$fichero.writeline("LogonServer:"+$env:logonserver)
$ficherohtml.writeline("LogonServer:"+$env:logonserver+"<br>")
if((Get-WmiObject -class Win32_ComputerSystem).domainrole -gt 2)
{
$searcher = new-object System.DirectoryServices.DirectorySearcher([ADSI]'')
$searcher.filter = "(&(objectClass=computer) (CN=$name))"
$computerdn = $searcher.findall()
$computerdn = $computerdn[0].path
if($computerdn -like "*$name*")
{
$fichero.writeline($computerdn.substring(7))
$ficherohtml.writeline($computerdn.substring(7)+"<br>")
}
}
$so = (get-wmiobject -class Win32_Operatingsystem -property caption).caption
$arqexists = get-wmiobject -class win32_operatingsystem
if($arqexists.osarchitecture -ne $null)
{
$arq = (get-wmiobject -class Win32_OperatingSystem -property OSArchitecture).OSArchitecture
}
$sp = (get-wmiobject -class Win32_OperatingSystem -property ServicePackMajorVersion).ServicePackMajorVersion
$fichero.writeline("OS: "+$so+" | SP:"+$sp+" | "+$arq)
$ficherohtml.writeline("OS: "+$so+" | SP:"+$sp+" | "+$arq+"<br>")
if($so -notlike "*2003*")
{
$activwindows = Get-wmiobject -Class SoftwareLicensingProduct |Where {$_.ApplicationID -eq "55c92734-d682-4d71-983e-d6ec3f16059f" -AND $_.PartialProductKey -ne $null}
if($activwindows.licensestatus -eq 1)
{
$activadowindows = "YES"
}else{
$activadowindows = "NO"
}
if($activwindows.EvaluationEndDate -eq "16010101000000.000000-000")
{
$evaluationenddate = "NEVER"
}else{
$evaluationenddate = $activwindows.EvaluationEndDate
}
$fichero.writeline("Windows Activation: "+$activwindows.description+" | Activated: "+$activadowindows+" | EvaluationEndDate: "+$evaluationenddate+" | PartialProductKey: "+$activwindows.PartialProductKey)
$ficherohtml.writeline("Windows Activation: "+$activwindows.description+" | Activated: "+$activadowindows+" | EvaluationEndDate: "+$evaluationenddate+" | PartialProductKey: "+$activwindows.PartialProductKey+"<br>")
}
$culture = (get-culture).displayname
$uiculture = (get-uiculture).displayname
$timezone = (get-WMIObject -class Win32_TimeZone).description
$fichero.writeline("Culture: "+$culture+" | Language: "+$uiculture+" | TimeZone: "+$timezone)
$ficherohtml.writeline("Culture: "+$culture+" | Language: "+$uiculture+" | TimeZone: "+$timezone+"<br>")
$installdate = (get-wmiobject -class Win32_OperatingSystem -property InstallDate).InstallDate
$installdate = [management.managementDateTimeConverter]::ToDateTime($installdate)
$boottime = (get-wmiobject -class Win32_OperatingSystem -property lastbootuptime).lastbootuptime
$boottime = [management.managementDateTimeConverter]::ToDateTime($boottime)
$fichero.writeline("Install Date: "+$installdate+" | Boot Time: "+$boottime)
$ficherohtml.writeline("Install Date: "+$installdate+" | Boot Time: "+$boottime+"<br>")
$fichero.writeline("--------------------")
$fichero.writeline("!#ProductKeys")
$ficherohtml.writeline("<A name=ProductKeys></A>")
$ficherohtml.writeline("<H3>ProductKeys</H3>")
#windowskey
if($so -like "*2003*")
{
$map="BCDFGHJKMPQRTVWXY2346789"
$sokey = Get-WmiObject -class Win32_OperatingSystem
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$name)
If($sokey.OSArchitecture -like '*64*')
{
$value = $Reg.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('DigitalProductId4')[0x34..0x42]
}else{
$value = $Reg.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('DigitalProductId')[0x34..0x42]
}
for ($i = 24; $i -ge 0; $i--)
{
$r = 0
for ($j = 14; $j -ge 0; $j--)
{
$r = ($r * 256) -bxor $value[$j]
$value[$j] = [math]::Floor([double]($r/24))
$r = $r % 24
}
$pkwindows = $map[$r] + $pkwindows
if (($i % 5) -eq 0 -and $i -ne 0)
{
$pkwindows = "-" + $pkwindows
}
}
$fichero.writeline("Windows ProductKey: "+$pkwindows+ " | OS: "+$so)
$ficherohtml.writeline("Windows ProductKey: "+$pkwindows+ " | OS: "+$so+"<br>")
}else{
$fichero.writeline("Windows PartialProductKey: "+$activwindows.PartialProductKey+ " | OS: "+$so)
$ficherohtml.writeline("Windows PartialProductKey: "+$activwindows.PartialProductKey+ " | OS: "+$so+"<br>")
}
#sqlkey
Function SQLKey {
param([byte[]]$data,[int]$version)
if ($version -ge 11)
{
$binArray = ($data)[0..66]
}else{
$binArray = ($data)[52..66]
}
$charsArray = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9"
for ($i = 24; $i -ge 0; $i--)
{
$k = 0
for ($j = 14; $j -ge 0; $j--)
{
$k = $k * 256 -bxor $binArray[$j]
$binArray[$j] = [math]::truncate($k / 24)
$k = $k % 24
}
$pksql = $charsArray[$k] + $pksql
if (($i % 5 -eq 0) -and ($i -ne 0))
{
$pksql = "-" + $pksql
}
}
return $pksql
}
if(test-path -path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\")
{
$wmi = [WMIClass]"\\.\root\default:stdRegProv"
$regValue1 = "DigitalProductId"
$regValue2 = "PatchLevel"
$regValue3 = "Edition"
$hklm = 2147483650
if(test-path -path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\Setup")
{
$regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\Setup"
$regdpid = "SOFTWARE\Microsoft\Microsoft SQL Server\90\ProductID"
[string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue
[string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue
$dpid = $wmi.enumvalues($hklm,$regdpid).snames | ? {$_ -like "DigitalProduct*"}
if($dpid -ne $null)
{
$data = $wmi.GetBinaryValue($hklm,$regdpid,$dpid)
if($data.uvalue -ne $null)
{
$pksql = SQLKey $data.uvalue 10
$fichero.writeline("SQL 2005/2005R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver)
$ficherohtml.writeline("SQL 2005/2005R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver+"<br>")
}
}else{
$fichero.writeline("SQL 2005/2005R2 can't get ProductKey there is no key HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\90\ProductID")
$ficherohtml.writeline("SQL 2005/2005R2 can't get ProductKey there is no key HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\90\ProductID<br>")
}
}
if(test-path -path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Setup")
{
$regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Setup"
$data = $wmi.GetBinaryValue($hklm,$regPath,$regValue1)
[string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue
[string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue
if($data.uvalue -ne $null)
{
$pksql = SQLKey $data.uvalue 10
$fichero.writeline("SQL 2008/2008R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver)
$ficherohtml.writeline("SQL 2008/2008R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver+"<br>")
}
}
if(test-path -path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\110\Tools\Setup")
{
$regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\110\Tools\Setup"
$data = $wmi.GetBinaryValue($hklm,$regPath,$regValue1)
[string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue
[string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue
if($data.uvalue -ne $null)
{
$pksql = SQLKey $data.uvalue 11
$fichero.writeline("SQL 2012/2012R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver)
$ficherohtml.writeline("SQL 2012/2012R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver+"<br>")
}
}
if(test-path -path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\120\Tools\Setup")
{
$regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\120\Tools\Setup"
$data = $wmi.GetBinaryValue($hklm,$regPath,$regValue1)
[string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue
[string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue
if($data.uvalue -ne $null)
{
$pksql = SQLKey $data.uvalue 12
$fichero.writeline("SQL 2014/2014R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver)
$ficherohtml.writeline("SQL 2014/2014R2 ProductKey: "+$pksql+" | Edition: "+$sqledition+" | Version: "+$sqlver+"<br>")
}
}
}
#vmwarekeys
$vcenterservices = @()
$vcenterservices += (get-service -displayname "*VirtualCenter*" | ? {$_.Status -eq "Running"})
if($vcenterservices.count -gt 0 -and (get-service -displayname "*VirtualCenter*" | ? {$_.Status -eq "Running"}) -ne $null)
{
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
if($error[0] -like "*snap*")
{
$error.Remove($error[0])
$fichero.writeline("VMware Licenses: VMware Powercli not installed")
$ficherohtml.writeline("VMware Licenses: VMware Powercli not installed:<br>")
}else{
#VMware vCenter connection, if your user does not have permission to connect, insert a user and password who has permission
write-host "VMware vCenter connection, if your user does not have permission to connect, insert a user and password who has permission"
connect-viserver localhost -WarningAction SilentlyContinue -erroraction SilentlyContinue
if($error[0] -like "*connect-viserver*")
{
$error.Remove($error[0])
$fichero.writeline("VMware Licenses: No permission to connect to vCenter, check user and password")
}else{
$fichero.writeline("VMware Licenses:")
$ficherohtml.writeline("VMware Licenses:<br>")
$fichero.writeline("Name | Key | Total | Used | Information")
$ficherohtml.writeline("Name | Key | Total | Used | Information:<br>")
$vmSI=Get-View ServiceInstance
$vmwarekeys=Get-View $vmSI.Content.LicenseManager
Foreach($vmwarekey in $vmwarekeys.Licenses)
{
foreach ($vmwarekeylabel in $vmwarekey.labels)
{
$vmwarekeyinfo = $vmwarekeylabel.value
}
$fichero.writeline($vmwarekey.Name+" | "+$vmwarekey.LicenseKey+" | "+$vmwarekey.total+" | "+$vmwarekey.Used+" | "+$vmwarekeyinfo)
$ficherohtml.writeline($vmwarekey.Name+" | "+$vmwarekey.LicenseKey+" | "+$vmwarekey.total+" | "+$vmwarekey.Used+" | "+$vmwarekeyinfo+"<br>")
}
}
}
}
$fichero.writeline("--------------------")
$fichero.writeline("!#Hardware")
$ficherohtml.writeline("<A name=Hardware></A>")
$ficherohtml.writeline("<H3>Hardware</H3>")
$marca = (get-wmiobject -class Win32_BIOS -property Manufacturer).Manufacturer
$modelo = (get-wmiobject -class Win32_ComputerSystem -property Model).Model
$bios = (get-wmiobject -class Win32_BIOS -property SMBIOSBIOSVersion).SMBIOSBIOSVersion
$sn = (get-wmiobject -class Win32_BIOS -property SerialNumber).SerialNumber
$fichero.writeline("Manufacturer: "+$marca+" | Model: "+$modelo+" | Bios: "+$bios+" | S/N: "+$sn)
$ficherohtml.writeline("Manufacturer: "+$marca+" | Model: "+$modelo+" | Bios: "+$bios+" | S/N: "+$sn+"<br>")
foreach ($win32cpu in (get-wmiobject -class Win32_Processor))
{
$cpu = $win32cpu.Name
$cpuspeed = $win32cpu.MaxClockSpeed
}
if($win32cpu.NumberOfLogicalProcessors -eq $null)
{
$cores = (get-wmiobject -class Win32_Processor).count
if($cores -eq $null)
{
$cores = 1
}
}else{
$cores = (get-WmiObject Win32_processor | measure-object -property Numberoflogicalprocessors -sum).sum
}
if((get-WmiObject Win32_processor).NumberOfcores -ne $null)
{
$coresfisicos = (get-WmiObject Win32_processor | measure-object -property NumberOfcores -sum).sum
}
if($coresfisicos -ne $null)
{
if(($cores / $coresfisicos) -eq 2)
{
$ht = "Yes"
}else{
$ht = "No"
}
}else{
$ht = "No"
}
$intelvtstatus = "off"
foreach ($intelvt in (Get-WmiObject -class win32_processor).VirtualizationFirmwareEnabled)
{
if($intelvt -eq $true)
{
$intelvtstatus = "on"
}
}
$fichero.writeline("CPU: "+$cpu+" | x "+$cores+" | "+$cpuspeed+" mhz | HT: "+$ht+" | IntelVT: "+$intelvtstatus)
$ficherohtml.writeline("CPU: "+$cpu+" | x "+$cores+" | "+$cpuspeed+" mhz | HT: "+$ht+" | IntelVT: "+$intelvtstatus+"<br>")
$ram = [int]((get-wmiobject -class Win32_ComputerSystem -property TotalPhysicalMemory).TotalPhysicalMemory / 1024 /1024)
$fichero.writeline("RAM: "+$ram+"MB")
$ficherohtml.writeline("RAM: "+$ram+"MB"+"<br>")
$discos = get-wmiobject -class Win32_DiskDrive
foreach ($disco in $discos)
{
$total = [int]($disco.size / 1024 / 1024 / 1024)
$fichero.writeline($disco.Name+" | TotalGB: "+$total)
$ficherohtml.writeline($disco.Name+" | TotalGB: "+$total+"<br>")
}
$particiones = get-wmiobject -class Win32_LogicalDisk | ? {$_.DriveType -eq 3}
$totalparticiones = 0
$ocupadoparticiones = 0
foreach ($particion in $particiones)
{
$total = [int]($particion.size / 1024 / 1024 / 1024)
$libre = [int]($particion.freespace / 1024 / 1024 / 1024)
$totalparticiones += $total
$ocupado = $total - $libre
$ocupadoparticiones += $ocupado
if($libre -lt 2)
{
$revision += $particion.caption+" less 2GB free | FreeGB: "+$libre
}
$fichero.writeline($name +" | "+$particion.caption+" | "+$particion.volumename+" | TotalGB: "+$total+" | FreeGB: "+$libre+" | SN: "+$particion.VolumeSerialNumber)
$ficherohtml.writeline($name +" | "+$particion.caption+" | "+$particion.volumename+" | TotalGB: "+$total+" | FreeGB: "+$libre+" | SN: "+$particion.VolumeSerialNumber+"<br>")
}
$fichero.writeline("............")
$ficherohtml.writeline("............<br>")
$fichero.writeline("TotalGB: "+$totalparticiones+" | OccupiedGB: "+$ocupadoparticiones)
$ficherohtml.writeline("TotalGB: "+$totalparticiones+" | OccupiedGB: "+$ocupadoparticiones+"<br>")
foreach ($pagefile in (get-wmiobject -class Win32_PageFile))
{
$fichero.writeline($pagefile.caption+" | size "+[int]($pagefile.filesize/1024/1024)+" | minimum "+$pagefile.InitialSize+" | maximum "+$pagefile.maximumsize)
$ficherohtml.writeline($pagefile.caption+" | size "+[int]($pagefile.filesize/1024/1024)+" | minimum "+$pagefile.InitialSize+" | maximum "+$pagefile.maximumsize+"<br>")
}
$fichero.writeline("!!#Devices:")
$ficherohtml.writeline("<A name=Devices></A>")
$ficherohtml.writeline("<H3>Devices</H3>")
$devices = gwmi Win32_PnPSignedDriver
$fichero.writeline("__NICs:__")
$ficherohtml.writeline("<b>NICs:</b><br>")
$hwnics = $devices | ? {$_.DeviceClass -eq "NET" -and $_.Manufacturer -ne "Microsoft" -and $_.Manufacturer -ne "McAfee"} | Sort DeviceName
$hwnics_speed = Get-WmiObject -class win32_networkadapter
foreach ($hwnic in $hwnics)
{
foreach ($hwnic_speed in $hwnics_speed)
{
if($hwnic_speed.pnpdeviceid -eq $hwnic.deviceid)
{
$hwnic_descriptionso = $hwnic_speed.NetConnectionID
if($hwnic_speed.speed -eq $null)
{
if($hwnic_speed.netconnectionstatus -eq 2)
{
$nic_speed = "link but WMI shows no speed"
}else{
$nic_speed = "no link"
}
}else{
if($hwnic_speed.speed -eq 9223372036854775807)
{
$nic_speed = "no link"
}else{
$nic_speed = $hwnic_speed.speed/1000000
}
}
}
}
$fichero.writeline($hwnic.DeviceName+" | "+$hwnic_descriptionso+" | SpeedMB:"+$nic_speed+" | "+$hwnic.Manufacturer+" | Driver: "+$hwnic.DriverVersion+" | DriverDate: "+$hwnic.DriverDate+" | "+$hwnic.Location)
$ficherohtml.writeline($hwnic.DeviceName+" | "+$hwnic_descriptionso+" | SpeedMB:"+$nic_speed+" | "+$hwnic.Manufacturer+" | Driver: "+$hwnic.DriverVersion+" | DriverDate: "+$hwnic.DriverDate+" | "+$hwnic.Location+"<br>")
}
$fichero.writeline("__SCSI/RAID controllers:__")
$ficherohtml.writeline("<br><b>SCSI/RAID controllers:</b><br>")
$hwcontroladoras = $devices | ? {$_.DeviceClass -eq "SCSIADAPTER"} | Sort DeviceName
foreach ($hwcontroladora in $hwcontroladoras)
{
$fichero.writeline($hwcontroladora.DeviceName+" | "+$hwcontroladora.Manufacturer+" | Driver: "+$hwcontroladora.DriverVersion+" | DriverDate: "+$hwcontroladora.DriverDate+" | "+$hwcontroladora.PDO+" | "+$hwcontroladora.Location)
$ficherohtml.writeline($hwcontroladora.DeviceName+" | "+$hwcontroladora.Manufacturer+" | Driver: "+$hwcontroladora.DriverVersion+" | DriverDate: "+$hwcontroladora.DriverDate+" | "+$hwcontroladora.PDO+" | "+$hwcontroladora.Location+"<br>")
}
if((Get-WmiObject -Class "MSFC_FCAdapterHBAAttributes" -List -Namespace "root\WMI") -ne $null)
{
if((Get-WmiObject -class MSFC_FCAdapterHBAAttributes -namespace "root\WMI" -ErrorAction SilentlyContinue) -eq $null)
{
if($error[0] -like "*Incompatible*" -or $error[0] -like "*Not Supported*")
{
$error.Remove($error[0])
}
}else{
$hba = 1
$fichero.writeline("__HBAS:__")
$ficherohtml.writeline("<br><b>HBAS:</b><br>")
$hwhbas = @()
$hwhbas += Get-WmiObject -class MSFC_FCAdapterHBAAttributes -namespace "root\WMI" -ErrorAction SilentlyContinue
foreach ($hwhba in $hwhbas)
{
$hwhbaportwwns = Get-WmiObject -class MSFC_FibrePortHBAAttributes -namespace "root\WMI" | ? {$_.InstanceName -eq $hwhba.InstanceName} | Select -Expandproperty Attributes | % { ($_.PortWWN | % {"{0:x2}" -f $_}) -join ":"}
$fichero.writeline($hwhba.ModelDescription+" | "+$hwhba.NodeSymbolicName+" | "+$hwhba.Manufacturer+" | Ports: "+$hwhba.NumberOfPorts+" | Driver: "+$hwhba.DriverVersion+" | Firmware: "+$hwhba.FirmwareVersion+" | S/N: "+$hwhba.SerialNumber)
$ficherohtml.writeline($hwhba.ModelDescription+" | "+$hwhba.NodeSymbolicName+" | "+$hwhba.Manufacturer+" | Ports: "+$hwhba.NumberOfPorts+" | Driver: "+$hwhba.DriverVersion+" | Firmware: "+$hwhba.FirmwareVersion+" | S/N: "+$hwhba.SerialNumber+"<br>")
foreach($hwhbaportwwn in $hwhbaportwwns)
{
$fichero.writeline("PortWWN: "+$hwhbaportwwn)
$ficherohtml.writeline("PortWWN: "+$hwhbaportwwn+"<br>")
}
}
}
}
if((Get-WmiObject -Namespace root\wmi -list "MPIO_DISK_INFO").name -eq "MPIO_DISK_INFO")
{
$fichero.writeline("__MPIO:__")
$ficherohtml.writeline("<br><b>MPIO:</b><br>")
$mpios = (get-wmiobject -Namespace root\wmi -Class mpio_disk_info).driveinfo
foreach($mpio in $mpios)
{
$fichero.writeline($mpio.Name + " | Paths:" +$mpio.NumberPaths + " | " + $mpio.DsmName + " | " + $mpio.SerialNumber)
$ficherohtml.writeline($mpio.Name + " | Paths:" +$mpio.NumberPaths + " | " + $mpio.DsmName + " | " + $mpio.SerialNumber +"<br>")
}
}
$fichero.writeline("__Disks:__")
$ficherohtml.writeline("<br><b>Disks:</b><br>")
$hwdiscos = $devices | ? {$_.DeviceClass -eq "DISKDRIVE"} | sort Location
foreach ($hwdisco in $hwdiscos)
{
$fichero.writeline($hwdisco.FriendlyName+" | "+$hwdisco.Manufacturer+" | Driver: "+$hwdisco.DriverVersion+" | DriverDate: "+$hwdisco.DriverDate+" | "+$hwdisco.PDO+" | "+$hwdisco.Location)
$ficherohtml.writeline($hwdisco.FriendlyName+" | "+$hwdisco.Manufacturer+" | Driver: "+$hwdisco.DriverVersion+" | DriverDate: "+$hwdisco.DriverDate+" | "+$hwdisco.PDO+" | "+$hwdisco.Location+"<br>")
}
if(test-path $env:programfiles"\hp\hponcfg\hponcfg.exe")
{
$indexRemote_Console = 1
$fichero.writeline("!!#Remote Console:")
$ficherohtml.writeline("<A name=Remote Console></A>")
$ficherohtml.writeline("<H4>Remote Console</H4>")
$rcilo = & $env:programfiles"\hp\hponcfg\hponcfg.exe" /get_hostinfo
& $env:programfiles"\hp\hponcfg\hponcfg.exe" /w rc.txt
if(test-path rc.txt)
{
$rcilo += get-content rc.txt
}
$fichero.writeline("HP ILO Config:")
$ficherohtml.writeline("HP ILO Config:<br>")
foreach ($line in $rcilo)
{
if($line -like "*<IP_ADDRESS VALUE*")
{
$rcip = ($line -split '"')[1]
}
if($line -like "*<*" -and $line -like "*>*")
{
$line = ($line -split "<" -split ">")[1]
}
$fichero.writeline($line)
$ficherohtml.writeline($line+"<br>")
}
}
$fichero.writeline("--------------------")
$fichero.writeline("!#Performance")
$ficherohtml.writeline("<A name=Performance></A>")
$ficherohtml.writeline("<H3>Performance</H3>")
$fichero.writeline("Date | CPUuse | RAMfree/total | Diskuse | DiskLatencyms | Netuse | CPUstolentime(only vmware)")
$ficherohtml.writeline("Date | CPUuse | RAMfree/total | Diskuse | DiskLatencyms | Netuse | CPUstolentime(only vmware)<br>")
for($i=1; $i -le $numoutperformance; $i++)
{
start-sleep 5
$fecha = (get-date).tostring()
$perfcpu = [int](Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average).average
$perframlibre = [int]((Get-WmiObject win32_OperatingSystem).FreePhysicalMemory / 1024)
#perfwritelatency perfreadlatency and perfiops
if((Get-Counter -ListSet * | ? {$_.countersetname -eq "PhysicalDisk"}).countersetname -eq "PhysicalDisk")
{
$perfreadlatency = [int]((((Get-Counter "\PhysicalDisk(*)\Avg. Disk sec/Read").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue) * 1000)
$perfwritelatency = [int]((((Get-Counter "\PhysicalDisk(*)\Avg. Disk sec/Write").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue) * 1000)
$perfiops = [int](((Get-Counter "\PhysicalDisk(*)\Disk Transfers/sec").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue)
}
elseif((Get-Counter -ListSet * | ? {$_.countersetname -eq "DiscoFísico"}).countersetname -eq "DiscoFísico")
{
$perfreadlatency = [int]((((Get-Counter "\DiscoFísico(*)\Media en segundos/lectura").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue) * 1000)
$perfwritelatency = [int]((((Get-Counter "\DiscoFísico(*)\Media en segundos/escritura").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue) * 1000)
$perfiops = [int](((Get-Counter "\DiscoFísico(*)\Transferencias de s.").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue)
}
elseif((Get-Counter -ListSet * | ? {$_.countersetname -eq "Disco Físico"}).countersetname -eq "Disco Físico")
{
$perfreadlatency = [int]((((Get-Counter "\Disco Físico(*)\Promedio de segundos de disco/lectura").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue) * 1000)
$perfwritelatency = [int]((((Get-Counter "\Disco Físico(*)\Promedio de segundos de disco/escritura").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue) * 1000)
$perfiops = [int](((Get-Counter "\Disco Físico(*)\Transferencias de disco/s").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue)
}
#get max latency read or write
if($perfreadlatency -lt $perfwritelatency)
{
$perflatency = $perfwritelatency
}
else
{
$perflatency = $perfreadlatency
}
#vmware cpu stolen time
if((Get-WmiObject -list | ? {$_.name -eq "Win32_PerfRawData_vmGuestLib_VCPU"}).name -eq "Win32_PerfRawData_vmGuestLib_VCPU")
{
if((Get-Counter -list * | ? {$_.countersetname -like "VM Processor"}).countersetname -eq "VM Processor")
{
$perfcpustolentime = [int]((((Get-Counter "\VM Processor(*)\CPU stolen time").countersamples | ? {$_.Instancename -eq "_total"}).cookedvalue) * 1000)
}
}
#usage of disk
if((Get-WmiObject -list | ? {$_.name -eq "Win32_PerfFormattedData_PerfDisk_PhysicalDisk"}).name -eq "Win32_PerfFormattedData_PerfDisk_PhysicalDisk")
{
$perfdisco = [int]((get-WmiObject Win32_PerfFormattedData_PerfDisk_PhysicalDisk | measure-object -property DiskBytespersec -sum).sum / 1024 / 1024)
}else{
$perfdisco = "N/A"
}
#usage of net
if((Get-WmiObject -list | ? {$_.name -eq "Win32_PerfFormattedData_Tcpip_NetworkInterface"}).name -eq "Win32_PerfFormattedData_Tcpip_NetworkInterface")
{
$perfred = [int]((get-WmiObject Win32_PerfFormattedData_Tcpip_NetworkInterface | measure-object -property BytesTotalPersec -sum).sum / 1024 / 1024)
}else{
$perfred = "N/A"
}
#thresholds for review section
if($perfcpu -gt 75 -or $perframlibre -lt 1000 -or $perfdisco -gt 50 -or $perflatency -gt 25 -or $perfred -gt 50 -or $perfiops -gt 500)
{
$revision += "performance (cpu > 75% or ramfree < 1000MB or usedisk > 50MB/s or iops > 500 or disklatencyms > 25 or usenet > 50MB/s) | " + $fecha+" CPU%use: "+$perfcpu+" RAMtotal: "+$ram+"MB RAMfree: "+$perframlibre+"MB DiskMBpersec: "+$perfdisco+" DiskIOps: " +("{0:D4}" -f $perfiops)+ " DiskLatencyms: "+$perflatency+" MB NetUse: "+$perfred+"MB"
}
$fichero.writeline($fecha+" | CPUuse: "+("{0:D3}" -f $perfcpu)+"% | RAMfree/total: "+("{0:D5}" -f $perframlibre)+"/"+("{0:D5}" -f $ram)+"MB | Diskuse: "+("{0:D4}" -f $perfdisco)+"MB | DiskIOps: " +("{0:D4}" -f $perfiops)+ " DiskLatencyms: "+("{0:D4}" -f $perflatency)+" | Netuse: "+("{0:D4}" -f $perfred)+"MB | CPUstolentime: "+$perfcpustolentime)
$ficherohtml.writeline($fecha+" | CPUuse: "+("{0:D3}" -f $perfcpu)+"% | RAMfree/total: "+("{0:D5}" -f $perframlibre)+"/"+("{0:D5}" -f $ram)+"MB | Diskuse: "+("{0:D4}" -f $perfdisco)+"MB | DiskIOps: " +("{0:D4}" -f $perfiops)+ " DiskLatencyms: "+("{0:D4}" -f $perflatency)+" | Netuse: "+("{0:D4}" -f $perfred)+"MB | CPUstolentime: "+$perfcpustolentime+"<br>")
$fichero.close()
$ficherohtml.close()
$fichero = New-Object System.IO.StreamWriter $pwd\$name".txt",$true
$ficherohtml = New-Object System.IO.StreamWriter $pwd\$name".html",$true
}
$fichero.writeline("--------------------")
$fichero.writeline("!#ENV")
$ficherohtml.writeline("<A name=ENV></A>")
$ficherohtml.writeline("<H3>ENV</H3>")
$env = get-childitem env: | select Name,Value
foreach ($key in $env)
{
$key.psobject.properties | foreach{$fichero.write($_.Name +": "+ $_.Value+" |");$ficherohtml.write($_.Name +": "+ $_.Value+" |")}
$fichero.writeline("")
$ficherohtml.writeline("<br>")
}
$fichero.writeline("--------------------")
$fichero.writeline("!#Eventlog")
$ficherohtml.writeline("<A name=Eventlog></A>")
$ficherohtml.writeline("<H3>Eventlog</H3>")
$eventlogs = Get-EventLog -list
$fichero.writeline("Eventlog Info, it is recommendable to have at least 7 days of history")
$ficherohtml.writeline("Eventlog Info, it is recommendable to have at least 7 days of history<br>")
$fichero.writeline("Log | MaxKB | History | Entries | Action | Retain")
$ficherohtml.writeline("Log | MaxKB | History | Entries | Action | Retain<br>")
if($so -notlike "*2003*")
{
foreach($eventlog in $eventlogs)
{
$eventlog_oldtime = "N/A"
$eventlog_entries = $eventlog.entries.count
if($eventlog_entries -gt 0)
{
$eventlog_oldtime = get-date ((Get-WinEvent -logname $eventlog.log -Oldest -maxevents 1).TimeCreated) -format yyyyMMdd_HH:mm
}
$fichero.writeline($eventlog.log + " | " + $eventlog.MaximumKilobytes + " | " + $eventlog_oldtime + " | " + $eventlog_entries + " | " + $eventlog.OverflowAction + " | " + $eventlog.MinimumRetentionDays)
$ficherohtml.writeline($eventlog.log + " | " + $eventlog.MaximumKilobytes + " | " + $eventlog_oldtime + " | " + $eventlog_entries + " | " + $eventlog.OverflowAction + " | " + $eventlog.MinimumRetentionDays+"<br>")
}
}else{
$fichero.writeline("w2003, cant use get-winevent command to get info of eventlogs")
$ficherohtml.writeline("w2003, cant use get-winevent command to get info of eventlogs<br>")
}
$fichero.writeline("--------------------")
$fichero.writeline("!#Startup Programs")
$ficherohtml.writeline("<A name=Startup Programs></A>")
$ficherohtml.writeline("<H3>Startup Programs</H3>")
$startup_programs = Get-WmiObject -class win32_startupcommand | ? {$_.command -notlike "*desktop.ini*" -and $_.command -notlike "*ctfmon.exe*"} | sort Location,Caption
$fichero.writeline("Caption | User | Command | Location")
$ficherohtml.writeline("Caption | User | Command | Location<br>")
foreach ($startup_program in $startup_programs)
{
$fichero.writeline($startup_program.caption + " | " + $startup_program.user + " | " + $startup_program.command + " | " + $startup_program.location)
$ficherohtml.writeline($startup_program.caption + " | " + $startup_program.user + " | " + $startup_program.command + " | " + $startup_program.location +"<br>")
}
$fichero.writeline("--------------------")
$fichero.writeline("!#Net")
$ficherohtml.writeline("<A name=Net></A>")
$ficherohtml.writeline("<H3>Net</H3>")
$fichero.writeline("!!#ipconfig")
$ficherohtml.writeline("<A name=ipconfig></A>")
$ficherohtml.writeline("<H4>ipconfig</H4>")
$fichero.writeline("ipconfig /all :")
$ficherohtml.writeline("ipconfig /all :<br>")
$ipconfig = ipconfig /all
foreach ($line in $ipconfig)
{
$fichero.writeline($line)
$ficherohtml.writeline($line+"<br>")
}
$powershellcmdletnicteaming = @()
$powershellcmdletnicteaming = Get-Command *get-netlbfoteam*
if($powershellcmdletnicteaming.count -gt 0)
{
$nicteaming = @()
$nicteaming = Get-NetLbfoTeam
if($nicteaming -ne $null)
{
$indexnicteaming = 1
$functions = $functions+"NicTeaming "
$fichero.writeline("!!#nicteaming")
$ficherohtml.writeline("<A name=nicteaming></A>")
$ficherohtml.writeline("<H4>nicteaming</H4>")
$fichero.writeline("config nic teaming :")
$ficherohtml.writeline("config nic teaming :<br>")
$nicteamingconfig = @()
$nicteamingconfig += Get-NetLbfoTeam | Out-string -Stream
$nicteamingconfig += Get-NetLbfoTeamMember | Out-string -Stream
$nicteamingconfig += Get-NetLbfoTeamNic | Out-string -Stream
foreach ($line in $nicteamingconfig)
{
if($line -ne $null -and $line -ne "")
{
$fichero.writeline($line)
$ficherohtml.writeline($line+"<br>")
}
}
}
}
if($so -notlike "*2003*")
{
$indexmtu = 1
$fichero.writeline("!!#MTU")
$ficherohtml.writeline("<A name=MTU></A>")
$ficherohtml.writeline("<H4>MTU</H4>")
$mtu = netsh interface ipv4 show interfaces
foreach ($line in $mtu)
{
$fichero.writeline($line)
$ficherohtml.writeline($line+"<br>")
}
}
$fichero.writeline("!!#routes")
$ficherohtml.writeline("<A name=routes></A>")
$ficherohtml.writeline("<H4>routes</H4>")
$fichero.writeline("persistent routes:")
$ficherohtml.writeline("persistent routes:<br>")
$fichero.writeline("Net | Mask | GW")
$ficherohtml.writeline("Net | Mask | GW<br>")
foreach ($ruta in (Get-WmiObject -Class Win32_IP4PersistedRouteTable))
{
$fichero.writeline($ruta.destination+" | "+$ruta.mask+" | "+$ruta.nexthop)
$ficherohtml.writeline($ruta.destination+" | "+$ruta.mask+" | "+$ruta.nexthop+"<br>")
}
$fichero.writeline("!!#hosts file")
$ficherohtml.writeline("<A name=hosts file></A>")
$ficherohtml.writeline("<H4>hosts file</H4>")
$hostsfile = get-content c:\windows\system32\drivers\etc\hosts
$fichero.writeline("^")
foreach ($linea in $hostsfile)
{
if(!$linea.startswith("#") -and $linea -ne "")
{
$fichero.writeline($linea)
$ficherohtml.writeline($linea+"<br>")
}
}
$fichero.writeline("^")
$fichero.writeline("!!#ntpclient")
$ficherohtml.writeline("<A name=ntpclient></A>")
$ficherohtml.writeline("<H4>ntpclient</H4>")
$ntpserver=(Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\w32time\Parameters').NtpServer
$ntptype=(Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\w32time\Parameters').type
$fichero.writeline("NTP Client Config: type "+$ntptype+" | NtpServer "+$ntpserver)
$ficherohtml.writeline("NTP Client Config: type "+$ntptype+" | NtpServer "+$ntpserver+"<br>")
$fichero.writeline("!!#other")
$ficherohtml.writeline("<A name=other></A>")
$ficherohtml.writeline("<H4>other</H4>")
$fichero.writeline("Firewall Windows: ")
$ficherohtml.writeline("Firewall Windows: <br>")
if($so -like "*2003*")
{
$fw2003 = netsh.exe firewall show state
foreach ($linea in $fw2003)
{
$fichero.writeline($linea)
$ficherohtml.writeline($linea+"<br>")
}
}else{
if((get-service MpsSvc).status -ne "Running")
{
$fichero.writeline("FW service not running")
$ficherohtml.writeline("FW service not running<br>")
}else{
$fwdomain = netsh.exe advfirewall show domainprofile | select-string state,estado
$fwprivate = netsh.exe advfirewall show privateprofile | select-string state,estado
$fwpublic = netsh.exe advfirewall show publicprofile | select-string state,estado
$fichero.writeline("FW Perfil Domain: "+$fwdomain)
$fichero.writeline("FW Private Domain: "+$fwprivate)
$fichero.writeline("FW Public Domain: "+$fwpublic)
$ficherohtml.writeline("FW Perfil Domain: "+$fwdomain+"<br>")
$ficherohtml.writeline("FW Private Domain: "+$fwprivate+"<br>")
$ficherohtml.writeline("FW Public Domain: "+$fwpublic+"<br>")
}
}
$fichero.writeline("Config RDP")
$ficherohtml.writeline("Config RDP<br>")
if ((Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server').fDenyTSConnections -eq 1)
{
$fichero.writeline("RDP not enabled")
$ficherohtml.writeline("RDP not enabled<br>")
}elseif((Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP*').UserAuthentication -eq 1)
{
$fichero.writeline("RDP enabled only client with NLA")
$ficherohtml.writeline("RDP enabled only client with NLA<br>")
}else{
$fichero.writeline("RDP enabled with any client")
$ficherohtml.writeline("RDP enabled with any client<br>")
}
if($so -notlike "*2003*")
{
$rdpnicinterface = (Get-WmiObject Win32_TSNetworkadaptersetting -Namespace "root\cimv2\TerminalServices").NetworkAdapterName
}else{
$rdpnicinterface = (gwmi Win32_TSNetworkAdapterSetting).networkadaptername
}
$fichero.writeline("RDP enabled in nic interface/s:"+$rdpnicinterface)
$ficherohtml.writeline("RDP enabled in nic interface/s:"+$rdpnicinterface+"<br>")
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('CurrentUser',$name)
$proxy = $reg.OpenSubkey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings")
$proxyenabled = $proxy.GetValue('ProxyEnable')
$proxyurl = $proxy.GetValue('ProxyServer')
if($proxyenabled -eq 1)
{
$fichero.writeline("With Proxy: "+$proxyurl)
$ficherohtml.writeline("With Proxy: "+$proxyurl+"<br>")
}else{
$fichero.writeline("No Proxy")
$ficherohtml.writeline("No Proxy<br>")
}
$fichero.writeline("!!#netstat")
$ficherohtml.writeline("<A name=netstat></A>")
$ficherohtml.writeline("<H4>netstat</H4>")
$fichero.writeline("netstat -es:")
$ficherohtml.writeline("netstat -es:<br>")
$netstat_es = c:\windows\system32\netstat.exe -es
foreach ($line in $netstat_es)
{
$fichero.writeline($line)
$ficherohtml.writeline($line+"<br>")
}
$fichero.writeline("netstat -abno:")
$ficherohtml.writeline("netstat -abno:<br>")
$netstat_abno = c:\windows\system32\netstat.exe -abno
foreach ($line in $netstat_abno)
{
$fichero.writeline($line)
$ficherohtml.writeline($line+"<br>")
}
if(test-path c:\windows\system32\nlb.exe)
{
$nlbdisplay = c:\windows\system32\nlb.exe display
foreach ($linea in $nlbdisplay)
{
if($linea -like "*ClusterName*")
{
$nlb_on = 1
}
}
if($nlb_on -eq 1)
{
$indexnlb = 1
$fichero.writeline("--------------------")
$fichero.writeline("!#NLB")
$ficherohtml.writeline("<A name=NLB></A>")
$ficherohtml.writeline("<H3>NLB</H3>")
foreach ($linea in $nlbdisplay)
{
$fichero.writeline($linea)
$ficherohtml.writeline($linea+"<br>")
}
$functions = $functions+"NLB "
}
}
$fichero.writeline("")
$fichero.writeline("Script Doc Windows Server, Jorge Navarro Manzano http://linkedin.com/in/jorgenavarromanzano")
$fichero.writeline("http://github.com/jorgenavarromanzano")
$ficherohtml.writeline("Script Doc Windows Server, Jorge Navarro Manzano<br>https://linkedin.com/in/jorgenavarromanzano<br>http://github.com/jorgenavarromanzano<br>")
if((get-command | ? {$_.name -eq "Get-Module"}).name -eq "Get-Module" -and (Get-WmiObject -Class Win32_service | ? {$_.name -eq "clussvc"}).name -eq "ClusSvc")
{
if((Get-Module -ListAvailable | ? {$_.Name -eq "failoverclusters"}).name -eq "failoverclusters")
{
Import-Module failoverclusters
$indexcluster = 1
$fichero.writeline("--------------------")
$fichero.writeline("!#Cluster")
$ficherohtml.writeline("<A name=Cluster></A>")
$ficherohtml.writeline("<H3>Cluster</H3>")
$functions = $functions+"Cluster "
$cluster = get-cluster
$clusterquorum = Get-ClusterQuorum
$fichero.writeline("Cluster: "+$cluster.Name+" | Domain: "+$cluster.Domain+" | Quorum: "+$clusterquorum.QuorumType)
$ficherohtml.writeline("Cluster: "+$cluster.Name+" | Domain: "+$cluster.Domain+" | Quorum: "+$clusterquorum.QuorumType+"<br>")
$clusternode = Get-ClusterNode
foreach ($node in $clusternode)
{
$fichero.writeline("Server: "+$node.Name+" | State: "+$node.State)
$ficherohtml.writeline("Server: "+$node.Name+" | State: "+$node.State+"<br>")
}
$clustergroup = Get-ClusterGroup
foreach ($group in $ClusterGroup)
{
$fichero.writeline("Group: "+$group.Name+" | State: "+$group.State+" | OwnerNode: "+$group.OwnerNode+" | DefaultOwner: "+$group.DefaultOwner+" | AutoFailbackType: "+$group.AutoFailbackType)
$ficherohtml.writeline("Group: "+$group.Name+" | State: "+$group.State+" | OwnerNode: "+$group.OwnerNode+" | DefaultOwner: "+$group.DefaultOwner+" | AutoFailbackType: "+$group.AutoFailbackType+"<br>")