Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
root = true

[*]
indent_style = space
indent_size = 4
tab_width = 4
20 changes: 10 additions & 10 deletions Convert-EmlFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<#
.SYNOPSIS
Function will parse an eml files.

.DESCRIPTION
Function will parse eml file and return a normalized object that can be used to extract infromation from the encoded file.

.PARAMETER EmlFileName
A string representing the eml file to parse.

.EXAMPLE
PS C:\> Convert-EmlFile -EmlFileName 'C:\Test\test.eml'

.OUTPUTS
System.Object
#>
Expand All @@ -25,21 +25,21 @@
[string]
$EmlFileName
)

# Instantiate new ADODB Stream object
$adoStream = New-Object -ComObject 'ADODB.Stream'

# Open stream
$adoStream.Open()

# Load file
$adoStream.LoadFromFile($EmlFileName)

# Instantiate new CDO Message Object
$cdoMessageObject = New-Object -ComObject 'CDO.Message'

# Open object and pass stream
$cdoMessageObject.DataSource.OpenObject($adoStream, '_Stream')

return $cdoMessageObject
}
56 changes: 28 additions & 28 deletions Export-Registry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ function Export-Registry
<#
.SYNOPSIS
Export registry item properties.

.DESCRIPTION
Export item properties for a given registry key.

By default results will be written to the pipeline unless the -ExportFormat parameter is used.

.PARAMETER KeyPath
A string representing the Key(s) to export in the PsDrive format IE: HKCU:\SOFTWARE\TestSoftware

.PARAMETER ExportFormat
A string representing the format to use for the export.
Possible values are:

Possible values are:

- CSV
- XML

PArameter is used in conjunction with the ExportPath paramter.

.PARAMETER ExportPath
A string representing the path where keys should be exported.

.PARAMETER NoBinaryData
When parameter is specified any binary data present in the registry key is removed.

.EXAMPLE
PS C:\> Export-RegistryNew -KeyPath 'HKCU:\SOFTWARE\TestSoftware'

.NOTES
Additional information about the function.
#>

[CmdletBinding(DefaultParameterSetName = 'PrintOnly')]
param
(
Expand Down Expand Up @@ -65,13 +65,13 @@ function Export-Registry
[switch]
$NoBinaryData
)

begin
{
# Initialize results array
# Initialize results array
[System.Collections.ArrayList]$returnData = @()
}

process
{
# Go through all paths
Expand All @@ -80,25 +80,25 @@ function Export-Registry
if ((Test-IsRegistryKey -KeyPath $path) -eq $true)
{
Write-Verbose "Getting properties for key: $path"

# Get registry item
$paramGetItem = @{
Path = $path
ErrorAction = 'Stop'
}

[Microsoft.Win32.RegistryKey]$regItem = Get-Item @paramGetItem

# Get key properties
[array]$regItemProperties = $regItem.'Property'

if ($regItemProperties.Count -gt 0)
{
# Enumerate properties
foreach ($property in $regItemProperties)
{
Write-Verbose "Exporting $property"

# Append data to return array
[void]($returnData.Add([pscustomobject]@{
'Path' = $regItem
Expand All @@ -124,12 +124,12 @@ function Export-Registry
else
{
Write-Warning -Message "Key $path does not exist"

continue
}
}
}

end
{
# Check we have results
Expand All @@ -143,11 +143,11 @@ function Export-Registry
if ($PSBoundParameters.ContainsKey('NoBinaryData'))
{
Write-Verbose -Message 'Removing binary data from return values'

# Remove binary data
$returnData = $returnData | Where-Object { $_.Type -ne 'Binary' }
}

switch ($ExportFormat)
{
'csv'
Expand All @@ -161,14 +161,14 @@ function Export-Registry
$returnData | Export-Clixml -Path $ExportPath -Force
}
}

Write-Verbose -Message "Data written to $ExportPath"
}

default
{
Write-Verbose -Message 'No data will be exported'

# Print on screen only
$returnData
}
Expand Down
Loading
Loading