-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1024.html
More file actions
153 lines (142 loc) · 6.57 KB
/
1024.html
File metadata and controls
153 lines (142 loc) · 6.57 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="PoshCode - Community resources for PowerShell coders">
<meta name="author" content="Paul Brice">
<title>Network Config | Excel - PoshCode</title>
<link rel="stylesheet" href="https://poshcode.org/css/superhero.min.css">
<link rel="stylesheet" href="https://poshcode.org/css/main.css">
<link rel="stylesheet" href="https://poshcode.org/css/highlight/arta.css">
<style>
body {
padding-top: 50px;
padding-bottom: 20px;
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="https://PoshCode.org/">PoshCode</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div id="navbarResponsive" class="collapse navbar-collapse navbar-responsive-collapse navbar-right">
<ul class="nav navbar-nav nav-tabs ml-auto" id="tabs">
<li class="nav-item"><a class="nav-link" href="https://poshcode.org/">Join Us!</a></li>
<li class="nav-item"><a class="nav-link active show" href="https://poshcode.org/scripts" data-toggle="tab">Scripts</a></li>
<li class="nav-item"><a class="nav-link" href="https://poshcode.org/video">Videos</a></li>
</ul>
</div><!--/.navbar-collapse -->
</div>
</nav>
</header>
<div class="container">
<div class="blog-header">
<h1 class="blog-title">PoshCode</h1>
<p class="lead blog-description">Community resources for PowerShell coders</p>
</div>
<div class="row">
<div class="blog-post">
<h2 class="blog-post-title">Network Config | Excel</h2>
<p class="blog-post-meta">
<span class="blog-post-time">2009-04-14</span> by <a class="blog-post-author">Paul Brice</a>
</p>
<h3>Download <a href="https://poshcode.org/scripts/1024.ps1">Network Config | Excel.ps1</a></h3>
<p>Scan an [Array] of Windows 2003 Servers and export their Network Adapter Configuration into an Excel Spreadsheet.</p>
<pre><code class="language-powershell">$excel = New-Object -comobject Excel.Application
$excel.visible = $False #Change to True to see the excel build
$wbook = $excel.Workbooks.Add()
$wsheet = $wbook.Worksheets.Item(1)
$wsheet.Cells.Item(1,1) = "Date"
$wsheet.Cells.Item(1,2) = "Server"
$wsheet.Cells.Item(1,3) = "NETID"
$wsheet.Cells.Item(1,4) = "Description"
$wsheet.Cells.Item(1,5) = "MAC"
$wsheet.Cells.Item(1,6) = "IP"
$wsheet.Cells.Item(1,7) = "DHCPEnabled"
$wsheet.Cells.Item(1,8) = "DHCPServer"
$wsheet.Cells.Item(1,9) = "DNSServerSearchOrder"
$wsheet.Cells.Item(1,10) = "WINSPrimaryServer"
$wsheet.Cells.Item(1,11) = "WINSSecondaryServer"
$wsheet.Cells.Item(1,12) = "DomainDNSRegistrationEnabled"
$wsheet.Cells.Item(1,13) = "FullDNSRegistrationEnabled"
$wsheet.Cells.Item(1,14) = "WINSEnableLMHostsLookup"
$range = $wsheet.UsedRange
$range.Interior.ColorIndex = 19
$range.Font.ColorIndex = 11
$range.Font.Bold = $True
$iRow = 2
$AllAdapters = @("")
$InputFile = "C:\Scripts\Servers.txt"
$Servers = Get-Content $InputFile
ForEach($Server in $Servers)
{
$Adapters = Get-Wmiobject Win32_NetworkAdapterConfiguration -Computername `
$Server | Where-Object{$_.IPEnabled -eq $True}
ForEach($Adapter In $Adapters)
{
[String]$DNSServers = ""
$Adapters2 = Get-Wmiobject Win32_NetworkAdapter -Computername $Server `
| Where-Object{$_.Caption -eq $Adapter.Caption}
[String]$NetID = $Adapters2.NetConnectionID
If($Adapter.DNSServerSearchOrder -ne $Null){ForEach($Address In `
$Adapter.DNSServerSearchOrder){$DNSServers += "[" + $Address + "]"}}
$wsheet.Cells.Item($iRow,1) = Get-Date
$wsheet.Cells.Item($iRow,2) = $Server
$wsheet.Cells.Item($iRow,3) = $NETID
$wsheet.Cells.Item($iRow,4) = $Adapter.Description
$wsheet.Cells.Item($iRow,5) = $Adapter.MACAddress
$wsheet.Cells.Item($iRow,6) = $Adapter.IPAddress
$wsheet.Cells.Item($iRow,7) = $Adapter.DHCPEnabled
$wsheet.Cells.Item($iRow,8) = $Adapter.DHCPServer
$wsheet.Cells.Item($iRow,9) = $DNSServers
$wsheet.Cells.Item($iRow,10) = $Adapter.WINSPrimaryServer
$wsheet.Cells.Item($iRow,11) = $Adapter.WINSSecondaryServer
$wsheet.Cells.Item($iRow,12) = $Adapter.DomainDNSRegistrationEnabled
$wsheet.Cells.Item($iRow,13) = $Adapter.FullDNSRegistrationEnabled
$wsheet.Cells.Item($iRow,14) = $Adapter.WINSEnableLMHostsLookup
$iRow = $iRow + 1
}
}
$range.EntireColumn.AutoFilter()
$range.EntireColumn.AutoFit()
$excel.ActiveWorkbook.SaveAs("C:\Scripts\NetworkScan.xls")
$excel.ActiveWorkbook.Close
$excel.Application.Quit
</code></pre>
</div>
<!-- sidebar? -->
</div>
<hr>
<footer class="blog-footer">
<p>Generated by Joel "Jaykul" Bennett - 2018</p>
</footer>
</div> <!-- /container -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script src="/js/main.js"></script>
<script src="/js/vendor/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-59988721-1', 'auto');
ga('send', 'pageview');
$(function () {
$('#contentTabs a:first').tab('show')
})
</script>
</body>
</html>