|
185 | 185 | .\Convert-SqlServerInventoryClixmlToExcel.ps1 |
186 | 186 |
|
187 | 187 | #> |
188 | | -[cmdletBinding(SupportsShouldProcess=$True, DefaultParametersetName='computername_WindowsAuthentication')] |
| 188 | +[cmdletBinding(SupportsShouldProcess=$True, DefaultParametersetName='computername')] |
189 | 189 | param( |
190 | | - [Parameter(Mandatory=$true, ParameterSetName='dns_SQLAuthentication', HelpMessage='DNS Server(s)')] |
191 | | - [Parameter(Mandatory=$true, ParameterSetName='dns_WindowsAuthentication', HelpMessage='DNS Server(s)')] |
| 190 | + [Parameter(Mandatory=$true, ParameterSetName='dns', HelpMessage='DNS Server(s)')] |
192 | 191 | [alias('dns')] |
193 | 192 | [ValidatePattern('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^auto$|^automatic$')] |
194 | 193 | [string[]] |
195 | 194 | $DnsServer = 'automatic' |
196 | 195 | , |
197 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_SQLAuthentication', HelpMessage='DNS Domain Name')] |
198 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_WindowsAuthentication', HelpMessage='DNS Domain Name')] |
| 196 | + [Parameter(Mandatory=$false, ParameterSetName='dns', HelpMessage='DNS Domain Name')] |
199 | 197 | [alias('domain')] |
200 | 198 | [string] |
201 | 199 | $DnsDomain = 'automatic' |
202 | 200 | , |
203 | | - [Parameter(Mandatory=$true, ParameterSetName='subnet_SQLAuthentication', HelpMessage='Subnet (in CIDR notation)')] |
204 | | - [Parameter(Mandatory=$true, ParameterSetName='subnet_WindowsAuthentication', HelpMessage='Subnet (in CIDR notation)')] |
| 201 | + [Parameter(Mandatory=$true, ParameterSetName='subnet', HelpMessage='Subnet (in CIDR notation)')] |
205 | 202 | [ValidatePattern('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\\/]\d{1,2}$|^auto$|^automatic$')] |
206 | 203 | [string[]] |
207 | 204 | $Subnet = 'automatic' |
208 | 205 | , |
209 | | - [Parameter(Mandatory=$true, ParameterSetName='computername_SQLAuthentication', HelpMessage='Computer Name(s)')] |
210 | | - [Parameter(Mandatory=$true, ParameterSetName='computername_WindowsAuthentication', HelpMessage='Computer Name(s)')] |
| 206 | + [Parameter(Mandatory=$true, ParameterSetName='computername', HelpMessage='Computer Name(s)')] |
211 | 207 | [alias('computer')] |
212 | 208 | [string[]] |
213 | 209 | $ComputerName |
214 | 210 | , |
215 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_SQLAuthentication')] |
216 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_WindowsAuthentication')] |
217 | | - [Parameter(Mandatory=$false, ParameterSetName='subnet_SQLAuthentication')] |
218 | | - [Parameter(Mandatory=$false, ParameterSetName='subnet_WindowsAuthentication')] |
| 211 | + [Parameter(Mandatory=$false, ParameterSetName='dns')] |
| 212 | + [Parameter(Mandatory=$false, ParameterSetName='subnet')] |
219 | 213 | [ValidatePattern('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\\/]\d{1,2}$')] |
220 | 214 | [string[]] |
221 | 215 | $ExcludeSubnet |
222 | 216 | , |
223 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_SQLAuthentication')] |
224 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_WindowsAuthentication')] |
| 217 | + [Parameter(Mandatory=$false, ParameterSetName='dns')] |
225 | 218 | [ValidatePattern('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\\/]\d{1,2}$')] |
226 | 219 | [string[]] |
227 | 220 | $LimitSubnet |
228 | 221 | , |
229 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_SQLAuthentication')] |
230 | | - [Parameter(Mandatory=$false, ParameterSetName='dns_WindowsAuthentication')] |
231 | | - [Parameter(Mandatory=$false, ParameterSetName='subnet_SQLAuthentication')] |
232 | | - [Parameter(Mandatory=$false, ParameterSetName='subnet_WindowsAuthentication')] |
| 222 | + [Parameter(Mandatory=$false, ParameterSetName='dns')] |
| 223 | + [Parameter(Mandatory=$false, ParameterSetName='subnet')] |
233 | 224 | [string[]] |
234 | 225 | $ExcludeComputerName |
235 | 226 | , |
236 | | - [Parameter(Mandatory=$true, ParameterSetName='dns_SQLAuthentication') ] |
237 | | - [Parameter(Mandatory=$true, ParameterSetName='subnet_SQLAuthentication') ] |
238 | | - [Parameter(Mandatory=$true, ParameterSetName='computername_SQLAuthentication') ] |
239 | | - [ValidateNotNull()] |
| 227 | + [Parameter(Mandatory=$false)] |
240 | 228 | [System.String] |
241 | | - $Username |
| 229 | + $Username = $null |
242 | 230 | , |
243 | | - [Parameter(Mandatory=$true, ParameterSetName='dns_SQLAuthentication') ] |
244 | | - [Parameter(Mandatory=$true, ParameterSetName='subnet_SQLAuthentication') ] |
245 | | - [Parameter(Mandatory=$true, ParameterSetName='computername_SQLAuthentication') ] |
246 | | - [ValidateNotNull()] |
| 231 | + [Parameter(Mandatory=$false)] |
247 | 232 | [System.String] |
248 | | - $Password |
| 233 | + $Password = $null |
249 | 234 | , |
250 | 235 | [Parameter(Mandatory=$false)] |
251 | 236 | [ValidateRange(1,100)] |
@@ -387,43 +372,24 @@ $ParameterHash = @{ |
387 | 372 | IncludeDatabaseObjectPermissions = $IncludeDatabaseObjectPermissions |
388 | 373 | IncludeDatabaseObjectInformation = $IncludeDatabaseObjectInformation |
389 | 374 | IncludeDatabaseSystemObjects = $IncludeDatabaseSystemObjects |
| 375 | + Username = $Username |
| 376 | + Password = $Password |
390 | 377 | } |
391 | 378 |
|
392 | 379 | switch ($PsCmdlet.ParameterSetName) { |
393 | | - 'dns_SQLAuthentication' { |
394 | | - $ParameterHash.Add('Username',$Username) |
395 | | - $ParameterHash.Add('Password',$Password) |
396 | | - $ParameterHash.Add('DnsServer',$DnsServer) |
397 | | - $ParameterHash.Add('DnsDomain',$DnsDomain) |
398 | | - if ($ExcludeSubnet) { $ParameterHash.Add('ExcludeSubnet',$ExcludeSubnet) } |
399 | | - if ($LimitSubnet) { $ParameterHash.Add('IncludeSubnet',$LimitSubnet) } |
400 | | - if ($ExcludeComputerName) { $ParameterHash.Add('ExcludeComputerName',$ExcludeComputerName) } |
401 | | - } |
402 | | - 'dns_WindowsAuthentication' { |
| 380 | + 'dns' { |
403 | 381 | $ParameterHash.Add('DnsServer',$DnsServer) |
404 | 382 | $ParameterHash.Add('DnsDomain',$DnsDomain) |
405 | 383 | if ($ExcludeSubnet) { $ParameterHash.Add('ExcludeSubnet',$ExcludeSubnet) } |
406 | 384 | if ($LimitSubnet) { $ParameterHash.Add('IncludeSubnet',$LimitSubnet) } |
407 | 385 | if ($ExcludeComputerName) { $ParameterHash.Add('ExcludeComputerName',$ExcludeComputerName) } |
408 | 386 | } |
409 | | - 'subnet_SQLAuthentication' { |
410 | | - $ParameterHash.Add('Username',$Username) |
411 | | - $ParameterHash.Add('Password',$Password) |
| 387 | + 'subnet' { |
412 | 388 | $ParameterHash.Add('Subnet',$Subnet) |
413 | 389 | if ($ExcludeSubnet) { $ParameterHash.Add('ExcludeSubnet',$ExcludeSubnet) } |
414 | 390 | if ($ExcludeComputerName) { $ParameterHash.Add('ExcludeComputerName',$ExcludeComputerName) } |
415 | 391 | } |
416 | | - 'subnet_WindowsAuthentication' { |
417 | | - $ParameterHash.Add('Subnet',$Subnet) |
418 | | - if ($ExcludeSubnet) { $ParameterHash.Add('ExcludeSubnet',$ExcludeSubnet) } |
419 | | - if ($ExcludeComputerName) { $ParameterHash.Add('ExcludeComputerName',$ExcludeComputerName) } |
420 | | - } |
421 | | - 'computername_SQLAuthentication' { |
422 | | - $ParameterHash.Add('Username',$Username) |
423 | | - $ParameterHash.Add('Password',$Password) |
424 | | - $ParameterHash.Add('ComputerName',$ComputerName) |
425 | | - } |
426 | | - 'computername_WindowsAuthentication' { |
| 392 | + 'computername' { |
427 | 393 | $ParameterHash.Add('ComputerName',$ComputerName) |
428 | 394 | } |
429 | 395 | } |
|
0 commit comments