Skip to content

Conversation

@DISKonnectd
Copy link
Contributor

Create a generic script that will pull Value, Data and LastWriteTime from arbitrary keys supplied by the user, maybe it has its own configuration file with a list of keys provided.

$ErrorActionPreference = "SilentlyContinue"

## The following code is from
## Name: Get-RegistryKeyTimestamp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What license was this script released under? Attribution is great, but we need to make sure it's compatible as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this will keep any of your catch blocks from doing anything.

$Orrig_EAP = $ErrorActionPreference
$ErrorActionPreference = "SilentlyContinue"

Write-Host "before try"

try
{
    Write-Host "In try"
    Write-Error "Bad stuff happened"
    Write-Host "After error"
}
catch
{
    Write-Host "In catch"
}
finally
{
    Write-Host "In finally"
    $ErrorActionPreference = $Orrig_EAP
}

Write-Host "after try"
before try
In try
After error
In finally
after try

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ErrorActionPreference affects non-terminating errors.
Try/Catch/Finally is for handling terminating exceptions.


if ($Error) {
# Write the $Error to the $Errorlog
Write-Error "Get-RegistryKeyValData Error on $env:COMPUTERNAME"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to explicitly add the target's computer name. Error handling in the main script already takes care of that.

.SYNOPSIS
Get-RegistryKeyValData.ps1 retrieves the value of the provided key as
well as the last modified time of the key.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a .PARAMETER attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants