This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding function remove regkey and updating remove-registryvalue
- Loading branch information
1 parent
e79dc91
commit 3fea6db
Showing
3 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<# | ||
.SYNOPSIS | ||
Removes a complete key from the registry | ||
.DESCRIPTION | ||
Removes a complete key from the registry and returns true or false if successfull or not | ||
.EXAMPLE | ||
PS C:\> Remove-RegistryKey -Path "HKLM:\testkey" | ||
Removes the Key HKLM:\testkey | ||
.NOTES | ||
General notes | ||
.OUTPUTS | ||
Boolean value which corresponds to the outcome | ||
#> | ||
function Remove-RegistryKey | ||
{ | ||
param ( | ||
# the path to the value | ||
[Parameter()] | ||
[string] | ||
$KeyPath, | ||
|
||
# if should be logged to LogAnalytics | ||
[Parameter()] | ||
[switch] | ||
$Log | ||
) | ||
$PSDefaultParameterValues = $Global:PSDefaultParameterValues | ||
If(Test-Path $KeyPath) | ||
{ | ||
try | ||
{ | ||
Remove-Item -Path $KeyPath -ErrorAction Stop -Recurse -Force | ||
If($Log) { Send-ToLogAnalytics -message "Removed $KeyPath." } | ||
} | ||
catch | ||
{ | ||
If($Log) { Send-ToLogAnalytics -message "Could not remove $KeyPath. $($_.Exception) $($_.ErrorDetails)" } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters