Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #31 enhancement #144

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

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.

None yet

3 participants