# -------------------------------------------------------------------------------------------------
# Begin Common.ps1
# This defines all common initialization functions and fields for all powershell scripts
# -------------------------------------------------------------------------------------------------
# State type constants
$STATE_SUCCESS = "Success"
$STATE_WARNING = "Warning"
$STATE_ERROR = "Error"
Function LogError($message)
{
# Write to Console
Write-Warning "ERROR: $SCRIPT_NAME: $message"
#$momAPI.LogScriptEvent($SCRIPT_NAME, 101, $EVENT_TYPE_ERROR, $message)
}
Function LogInfo($message)
{
# Write to Console
Write-Host -ForegroundColor Green "INFO: $SCRIPT_NAME: $message"
#$momAPI.LogScriptEvent($SCRIPT_NAME, 104, $EVENT_TYPE_INFORMATION, $message)
}
Function LogVerbose($message)
{
# Write to Console
Write-Verbose "VERBOSE: $SCRIPT_NAME: $message"
#$momAPI.LogScriptEvent($SCRIPT_NAME, 105, $EVENT_TYPE_INFORMATION, $message)
}
Function ThrowAndExit($message)
{
throw $message
LogError($message)
exit
}
Function CheckAndLogError($message)
{
if($Error)
{
LogError($message)
LogError($Error)
exit
}
}
# Method to resolve path.
# Resolve the local path to a full path but do not resolve the network path.
Function ResolvePath($path)
{
$resolvedPath = $path
if(!$path.StartsWith('\\'))
{
# Resolve local path
$resolvedPath = resolve-path($path)
}
# -------------------------------------------------------------------------------------------------
# End of Common.ps1
# -------------------------------------------------------------------------------------------------
$StatePropertyBag = $momAPI.CreateTypedPropertyBag($PROPERTY_TYPE_STATE)
if ($StatePropertyBag -eq $null)
{
LogError("unable to create state property bag")
Exit
}