пятница, 24 октября 2008 г.

Create Registry Path in PowerShell


Here is script to create registry path (or separate key) in PowerShell



function vrIsRegistryPathContainsKey($basePath, $key)
{
if($key.Length -le 0)
{ return 0 }

$childItems = Get-ChildItem $basePath -Force -ErrorAction SilentlyContinue
foreach ($childItem in $childItems)
{
if($childItem.name -match $key)
{
return 1
}
}
return 0
}

function vrCreateRegistryPath($basePath, $createdPath)
{
$pathTokens = $createdPath.split("\")
foreach ($pathToken in $pathTokens)
{
if($pathToken.Length -le 0)
{ break }

if(-not(vrIsRegistryPathContainsKey $basePath $pathToken))
{
echo ('not found ' + $pathToken);
New-Item -Path $basePath -Name $pathToken
}
$basePath = $basePath + "\" + $pathToken
echo ('basepath ' + $basePath);
}
}


Usage:
vrCreateRegistryPath 'Microsoft.PowerShell.Core\Registry::\HKEY_LOCAL_MACHINE\SOFTWARE' 'Key\SubKey1\Subkey2\'


вторник, 21 октября 2008 г.

Veeam Reporter v.3.0 Enterprise Release


We did it! Veeam Reporter v.3.0 Enterprise for VMware infrastructure 3 has been released today. See more...

Using .NET Enum values in PowerShell


For using values of enum nested in type and/or namespace of already loaded assembly in PowerShell you would use following statement:


[SomeNamespace.EnclosingType+NestedEnum]::EnumValue