@@ -3369,7 +3369,13 @@ Outputs custom PSObjects with detailed information about the DNS zone.
3369
3369
$Out.PSObject.TypeNames.Insert(0, 'PowerView.DNSZone')
3370
3370
$Out
3371
3371
}
3372
- try { $Results.dispose() } catch {}
3372
+
3373
+ if ($Results) {
3374
+ try { $Results.dispose() }
3375
+ catch {
3376
+ Write-Verbose "[Get-DomainDFSShare] Error disposing of the Results object: $_"
3377
+ }
3378
+ }
3373
3379
$DNSSearcher1.dispose()
3374
3380
}
3375
3381
@@ -3386,7 +3392,12 @@ Outputs custom PSObjects with detailed information about the DNS zone.
3386
3392
$Out.PSObject.TypeNames.Insert(0, 'PowerView.DNSZone')
3387
3393
$Out
3388
3394
}
3389
- try { $Results.dispose() } catch {}
3395
+ if ($Results) {
3396
+ try { $Results.dispose() }
3397
+ catch {
3398
+ Write-Verbose "[Get-DomainDNSZone] Error disposing of the Results object: $_"
3399
+ }
3400
+ }
3390
3401
}
3391
3402
catch {
3392
3403
Write-Verbose "[Get-DomainDNSZone] Error accessing 'CN=MicrosoftDNS,DC=DomainDnsZones'"
@@ -3554,7 +3565,13 @@ Outputs custom PSObjects with detailed information about the DNS record entry.
3554
3565
$Out
3555
3566
}
3556
3567
}
3557
- try { $Results.dispose() } catch {}
3568
+
3569
+ if ($Results) {
3570
+ try { $Results.dispose() }
3571
+ catch {
3572
+ Write-Verbose "[Get-DomainDNSRecord] Error disposing of the Results object: $_"
3573
+ }
3574
+ }
3558
3575
$DNSSearcher.dispose()
3559
3576
}
3560
3577
}
@@ -3622,7 +3639,7 @@ http://social.technet.microsoft.com/Forums/scriptcenter/en-US/0c5b3f83-e528-4d49
3622
3639
PROCESS {
3623
3640
if ($PSBoundParameters['Credential']) {
3624
3641
3625
- Write-Verbose " [Get-Domain] Using alternate credentials for Get-Domain"
3642
+ Write-Verbose ' [Get-Domain] Using alternate credentials for Get-Domain'
3626
3643
3627
3644
if ($PSBoundParameters['Domain']) {
3628
3645
$TargetDomain = $Domain
@@ -3652,7 +3669,12 @@ http://social.technet.microsoft.com/Forums/scriptcenter/en-US/0c5b3f83-e528-4d49
3652
3669
}
3653
3670
}
3654
3671
else {
3655
- [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
3672
+ try {
3673
+ [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
3674
+ }
3675
+ catch {
3676
+ Write-Verbose "[Get-Domain] Error retrieving the current domain: $_"
3677
+ }
3656
3678
}
3657
3679
}
3658
3680
}
@@ -4089,6 +4111,7 @@ the specified alternate credentials.
4089
4111
An ActiveDirectorySchemaClass returned from the found schema.
4090
4112
#>
4091
4113
4114
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
4092
4115
[OutputType([System.DirectoryServices.ActiveDirectory.ActiveDirectorySchemaClass])]
4093
4116
[CmdletBinding()]
4094
4117
Param(
@@ -4555,6 +4578,7 @@ PowerView.User.Raw
4555
4578
The raw DirectoryServices.SearchResult object, if -Raw is enabled.
4556
4579
#>
4557
4580
4581
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
4558
4582
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
4559
4583
[OutputType('PowerView.User')]
4560
4584
[OutputType('PowerView.User.Raw')]
@@ -4733,7 +4757,12 @@ The raw DirectoryServices.SearchResult object, if -Raw is enabled.
4733
4757
}
4734
4758
$User
4735
4759
}
4736
- try { $Results.dispose() } catch {}
4760
+ if ($Results) {
4761
+ try { $Results.dispose() }
4762
+ catch {
4763
+ Write-Verbose "[Get-DomainUser] Error disposing of the Results object: $_"
4764
+ }
4765
+ }
4737
4766
$UserSearcher.dispose()
4738
4767
}
4739
4768
}
@@ -4825,6 +4854,7 @@ DirectoryServices.AccountManagement.UserPrincipal
4825
4854
http://richardspowershellblog.wordpress.com/2008/05/25/system-directoryservices-accountmanagement/
4826
4855
#>
4827
4856
4857
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
4828
4858
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
4829
4859
[OutputType('DirectoryServices.AccountManagement.UserPrincipal')]
4830
4860
Param(
@@ -4968,6 +4998,7 @@ DirectoryServices.AccountManagement.UserPrincipal
4968
4998
http://richardspowershellblog.wordpress.com/2008/05/25/system-directoryservices-accountmanagement/
4969
4999
#>
4970
5000
5001
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
4971
5002
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
4972
5003
[OutputType('DirectoryServices.AccountManagement.UserPrincipal')]
4973
5004
Param(
@@ -5387,7 +5418,12 @@ http://blogs.technet.com/b/ashleymcglone/archive/2013/03/25/active-directory-ou-
5387
5418
$Results | Where-Object {$_} | ForEach-Object {
5388
5419
$GUIDs[(New-Object Guid (,$_.properties.schemaidguid[0])).Guid] = $_.properties.name[0]
5389
5420
}
5390
- try { $Results.dispose() } catch {}
5421
+ if ($Results) {
5422
+ try { $Results.dispose() }
5423
+ catch {
5424
+ Write-Verbose "[Get-DomainGUIDMap] Error disposing of the Results object: $_"
5425
+ }
5426
+ }
5391
5427
$SchemaSearcher.dispose()
5392
5428
}
5393
5429
catch {
@@ -5405,7 +5441,12 @@ http://blogs.technet.com/b/ashleymcglone/archive/2013/03/25/active-directory-ou-
5405
5441
$Results | Where-Object {$_} | ForEach-Object {
5406
5442
$GUIDs[$_.properties.rightsguid[0].toString()] = $_.properties.name[0]
5407
5443
}
5408
- try { $Results.dispose() } catch {}
5444
+ if ($Results) {
5445
+ try { $Results.dispose() }
5446
+ catch {
5447
+ Write-Verbose "[Get-DomainGUIDMap] Error disposing of the Results object: $_"
5448
+ }
5449
+ }
5409
5450
$RightsSearcher.dispose()
5410
5451
}
5411
5452
catch {
@@ -5761,7 +5802,12 @@ The raw DirectoryServices.SearchResult object, if -Raw is enabled.
5761
5802
$Computer
5762
5803
}
5763
5804
}
5764
- try { $Results.dispose() } catch {}
5805
+ if ($Results) {
5806
+ try { $Results.dispose() }
5807
+ catch {
5808
+ Write-Verbose "[Get-DomainComputer] Error disposing of the Results object: $_"
5809
+ }
5810
+ }
5765
5811
$CompSearcher.dispose()
5766
5812
}
5767
5813
}
@@ -5900,6 +5946,7 @@ PowerView.ADObject.Raw
5900
5946
The raw DirectoryServices.SearchResult object, if -Raw is enabled.
5901
5947
#>
5902
5948
5949
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
5903
5950
[OutputType('PowerView.ADObject')]
5904
5951
[OutputType('PowerView.ADObject.Raw')]
5905
5952
[CmdletBinding()]
@@ -6044,7 +6091,12 @@ The raw DirectoryServices.SearchResult object, if -Raw is enabled.
6044
6091
}
6045
6092
$Object
6046
6093
}
6047
- try { $Results.dispose() } catch {}
6094
+ if ($Results) {
6095
+ try { $Results.dispose() }
6096
+ catch {
6097
+ Write-Verbose "[Get-DomainObject] Error disposing of the Results object: $_"
6098
+ }
6099
+ }
6048
6100
$ObjectSearcher.dispose()
6049
6101
}
6050
6102
}
@@ -7622,7 +7674,12 @@ Custom PSObject with translated OU property fields.
7622
7674
$OU.PSObject.TypeNames.Insert(0, 'PowerView.OU')
7623
7675
$OU
7624
7676
}
7625
- try { $Results.dispose() } catch {}
7677
+ if ($Results) {
7678
+ try { $Results.dispose() }
7679
+ catch {
7680
+ Write-Verbose "[Get-DomainOU] Error disposing of the Results object: $_"
7681
+ }
7682
+ }
7626
7683
$OUSearcher.dispose()
7627
7684
}
7628
7685
}
@@ -7876,7 +7933,12 @@ Custom PSObject with translated site property fields.
7876
7933
$Site.PSObject.TypeNames.Insert(0, 'PowerView.Site')
7877
7934
$Site
7878
7935
}
7879
- try { $Results.dispose() } catch {}
7936
+ if ($Results) {
7937
+ try { $Results.dispose() }
7938
+ catch {
7939
+ Write-Verbose "[Get-DomainSite] Error disposing of the Results object"
7940
+ }
7941
+ }
7880
7942
$SiteSearcher.dispose()
7881
7943
}
7882
7944
}
@@ -8137,7 +8199,12 @@ Custom PSObject with translated subnet property fields.
8137
8199
$Subnet
8138
8200
}
8139
8201
}
8140
- try { $Results.dispose() } catch {}
8202
+ if ($Results) {
8203
+ try { $Results.dispose() }
8204
+ catch {
8205
+ Write-Verbose "[Get-DomainSubnet] Error disposing of the Results object: $_"
8206
+ }
8207
+ }
8141
8208
$SubnetSearcher.dispose()
8142
8209
}
8143
8210
}
@@ -8411,6 +8478,7 @@ Custom PSObject with translated group property fields.
8411
8478
#>
8412
8479
8413
8480
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
8481
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
8414
8482
[OutputType('PowerView.Group')]
8415
8483
[CmdletBinding(DefaultParameterSetName = 'AllowDelegation')]
8416
8484
Param(
@@ -8595,7 +8663,12 @@ Custom PSObject with translated group property fields.
8595
8663
$Group.PSObject.TypeNames.Insert(0, 'PowerView.Group')
8596
8664
$Group
8597
8665
}
8598
- try { $Results.dispose() } catch {}
8666
+ if ($Results) {
8667
+ try { $Results.dispose() }
8668
+ catch {
8669
+ Write-Verbose "[Get-DomainGroup] Error disposing of the Results object"
8670
+ }
8671
+ }
8599
8672
$GroupSearcher.dispose()
8600
8673
}
8601
8674
}
@@ -8667,6 +8740,7 @@ Creates the 'TestGroup' group with the specified description using the specified
8667
8740
DirectoryServices.AccountManagement.GroupPrincipal
8668
8741
#>
8669
8742
8743
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
8670
8744
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
8671
8745
[OutputType('DirectoryServices.AccountManagement.GroupPrincipal')]
8672
8746
Param(
@@ -9137,6 +9211,7 @@ http://www.powershellmagazine.com/2013/05/23/pstip-retrieve-group-membership-of-
9137
9211
#>
9138
9212
9139
9213
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
9214
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
9140
9215
[OutputType('PowerView.GroupMember')]
9141
9216
[CmdletBinding(DefaultParameterSetName = 'None')]
9142
9217
Param(
@@ -10117,7 +10192,12 @@ A custom PSObject describing the distributed file systems.
10117
10192
}
10118
10193
}
10119
10194
}
10120
- try { $Results.dispose() } catch {}
10195
+ if ($Results) {
10196
+ try { $Results.dispose() }
10197
+ catch {
10198
+ Write-Verbose "[Get-DomainDFSShare] Get-DomainDFSShareV1 error disposing of the Results object: $_"
10199
+ }
10200
+ }
10121
10201
$DFSSearcher.dispose()
10122
10202
10123
10203
if ($pkt -and $pkt[0]) {
@@ -10194,7 +10274,12 @@ A custom PSObject describing the distributed file systems.
10194
10274
}
10195
10275
}
10196
10276
}
10197
- try { $Results.dispose() } catch {}
10277
+ if ($Results) {
10278
+ try { $Results.dispose() }
10279
+ catch {
10280
+ Write-Verbose "[Get-DomainDFSShare] Error disposing of the Results object: $_"
10281
+ }
10282
+ }
10198
10283
$DFSSearcher.dispose()
10199
10284
}
10200
10285
catch {
@@ -10601,6 +10686,7 @@ The raw DirectoryServices.SearchResult object, if -Raw is enabled.
10601
10686
#>
10602
10687
10603
10688
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
10689
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
10604
10690
[OutputType('PowerView.GPO')]
10605
10691
[OutputType('PowerView.GPO.Raw')]
10606
10692
[CmdletBinding(DefaultParameterSetName = 'None')]
@@ -10870,7 +10956,12 @@ The raw DirectoryServices.SearchResult object, if -Raw is enabled.
10870
10956
}
10871
10957
$GPO
10872
10958
}
10873
- try { $Results.dispose() } catch {}
10959
+ if ($Results) {
10960
+ try { $Results.dispose() }
10961
+ catch {
10962
+ Write-Verbose "[Get-DomainGPO] Error disposing of the Results object: $_"
10963
+ }
10964
+ }
10874
10965
$GPOSearcher.dispose()
10875
10966
}
10876
10967
}
@@ -17457,7 +17548,12 @@ Custom PSObject with translated domain API trust result fields.
17457
17548
$DomainTrust.PSObject.TypeNames.Insert(0, 'PowerView.DomainTrust.LDAP')
17458
17549
$DomainTrust
17459
17550
}
17460
- try { $Results.dispose() } catch {}
17551
+ if ($Results) {
17552
+ try { $Results.dispose() }
17553
+ catch {
17554
+ Write-Verbose "[Get-DomainTrust] Error disposing of the Results object: $_"
17555
+ }
17556
+ }
17461
17557
$TrustSearcher.dispose()
17462
17558
}
17463
17559
}
0 commit comments