Fujitsu.Servers.PRIMERGY.Linux.PS.CommonModule (DeployableResource)

Element properties:

TypeDeployableResource
File NameCommonModule.psm1
AccessibilityPublic

Source Code:

<DeployableResource ID="Fujitsu.Servers.PRIMERGY.Linux.PS.CommonModule" Accessibility="Public" FileName="CommonModule.psm1" HasNullStream="false"/>

File Content: CommonModule.psm1

#-------------------------------------------------------------------

# Fujitsu
# Copyright 2014-2019 FUJITSU LIMITED
#
# CommonModule.psm1
#
# Summary:
# Common module for Linux MP PowerShell scripts
#-------------------------------------------------------------------

$script:RootRegistryKey = "HKLM:\SOFTWARE\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-Lin"

function New-SCOMApiObject {
<#
.SYNOPSIS
Returns MOM.ScriptAPI/API mock object.
.DESCRIPTION
Function returns MOM.ScriptAPI object. If run outside management pack, returns mock for MOM.ScriptAPI.
.PARAMETER OutsideManagementPack
Set that script is run outside management pack.
.EXAMPLE
$oApi = New-SCOMApiObject -OutsideManagementPack
#>
Param ([switch] $OutsideManagementPack)

if ($OutsideManagementPack) {
Import-Module "$PSScriptRoot\..\..\..\..\..\Tests\Include\ScomApiMock.psm1"
return New-FakeMOMObject
} else {
return New-Object -ComObject "MOM.ScriptAPI"
}
}

function Expand-GZip {
<#
.SYNOPSIS
Decompress string compressed with GZip and encoded with Base64.
.DESCRIPTION
Function returns uncompressed and decoded string of compressed with GZip and encoded with Base64 string.
.PARAMETER Base64String
String to decompress.
.EXAMPLE
$sUncompressed = Expand-GZip -Base64String $sCompressedString
#>
Param (
[string] $Base64String
)
try {
$encoded = [System.Convert]::FromBase64String($Base64String)
$mem_stream = New-Object System.IO.MemoryStream
$mem_stream.Write($encoded, 0, $encoded.Length)
$mem_stream.Seek(0,0) | Out-Null
[System.IO.Compression.GZipStream] $deflate = New-Object System.IO.Compression.GZipStream($mem_stream, [System.IO.Compression.CompressionMode]::Decompress)
$reader = New-Object System.IO.StreamReader($deflate, [System.Text.Encoding]::UTF8)
return $reader.ReadToEnd()
} finally {
if ($reader -ne $Null) {
$reader.Dispose()
}
if ($deflate -ne $Null) {
$deflate.Dispose()
}
if ($mem_stream -ne $Null) {
$mem_stream.Dispose()
}
}
}

Export-ModuleMember -Variable 'RootRegistryKey'
Export-ModuleMember -Function 'New-SCOMApiObject'
Export-ModuleMember -Function 'Expand-GZip'