Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
!deploy Version 1.0.3 (#8)
Browse files Browse the repository at this point in the history
* Adding function remove regkey and updating remove-registryvalue
  • Loading branch information
MauRiEEZZZ authored Apr 7, 2020
1 parent e79dc91 commit 3fea6db
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
40 changes: 40 additions & 0 deletions src/Public/Remove-RegistryKey.ps1
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)" }
}
}
}
10 changes: 5 additions & 5 deletions src/Public/Remove-RegistryValue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ function Remove-RegistryValue
$Log
)
$PSDefaultParameterValues = $Global:PSDefaultParameterValues
If(Test-Path $RegistryPath)
If(Test-Path $Path)
{
If(Test-RegistryValue -Path $RegistryPath -Value $RegistryValue)
If(Test-RegistryValue -Path $Path -Value $RegistryValue)
{
try
{
Remove-ItemProperty -Path $RegistryPath -Name $RegistryValue -ErrorAction Stop
If($Log) { Send-ToLogAnalytics -message "Removed $RegistryValue in path $RegistryPath." }
Remove-ItemProperty -Path $Path -Name $RegistryValue -ErrorAction Stop
If($Log) { Send-ToLogAnalytics -message "Removed $Path in path $RegistryPath." }
}
catch
{
If($Log) { Send-ToLogAnalytics -message "Could not remove $RegistryValue in path $RegistryPath. $($_.Exception) $($_.ErrorDetails)" }
If($Log) { Send-ToLogAnalytics -message "Could not remove $Path in path $RegistryPath. $($_.Exception) $($_.ErrorDetails)" }
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/wrt.helpers.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
RootModule = 'wrt.helpers.psm1'

# Version number of this module.
ModuleVersion = '1.1.0'

ModuleVersion = '1.0.3'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down

0 comments on commit 3fea6db

Please sign in to comment.