Users

All Posts (3)

avatar

lberchten

Modify Embedded Script on Powershell Session with Powershell

avatar
avatar
avatar

Hello Richard

Sorry i have not found this post. Now it works, after i have reformat the Function and removed # before Write-Output $byteOutArray in this Function.

I have modified it to Read a ps1 File directly, the Script works now with the follow Code:

#Variables

##############################################################################################################

$powershell_script_source_path = "c:\temp\test.ps1"

$rdm_powershell_session_name = "testps"

#Functions

##############################################################################################################

function Get-CompressedByteArray{

[CmdletBinding()]

Param(

[Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)][byte[]] $byteArray = $(Throw("-byteArray is required"))

)

Process{

[System.IO.MemoryStream] $output = New-Object System.IO.MemoryStream

$gzipStream = New-Object System.IO.Compression.DeflateStream $output, ([IO.Compression.CompressionMode]::Compress)

$gzipStream.Write( $byteArray, 0, $byteArray.Length )

$gzipStream.Close()

$output.Close()

$tmp = $output.ToArray()

Write-Output $tmp

}

}

#Main Script

##############################################################################################################

#Read Powershell File Content and Compress it

[Byte[]] $bytes = [System.IO.File]::ReadAllBytes($powershell_script_source_path)

$CompressedBytes = Get-CompressedByteArray $bytes

#Update RDM Session with Compressed Powershell Script

$s = Get-RDMSession -Name $rdm_powershell_session_name

$s.PowerShell.EmbeddedScriptCompressed = $CompressedBytes

Set-RDMSession $s

Thanks for your fast help.

Best Regards

Lukas

Modify Embedded Script on Powershell Session with Powershell

avatar
avatar
avatar

Hello

I want to modify Embedded Powershell Scripts in Powershell

Sessions with Powershell himself.

In GUI I can Edit like the following:

 

But I would like to be able to edit this myself using

Powershell, but I can't find a way to do it. Is this possible?

As with the other documents, I tried with

"-IncludeDocumentsStoredInDatabase", but this does not work with

Powershell scripts stored in the DB.

Best Regards Lukas

Manage usergroups with powershell

avatar
avatar
avatar
avatar

For Information, i needed to get User assigned Roles yesterday:

You can get the Groups Names for a User with the follow Code:

$rdm_user = Get-RDMUser | Where {$_.Description -like $user_full_name}

$rdm_user_roles = @()

        [xml]$sec = $rdm_user.CustomSecurity

        foreach ($item in $sec.CustomSecurity.CustomRoles.String)

        {

            $role = Get-RDMRole | where {$_.ID -eq $item}

            $roleName = $role.Name

            if (!([string]::IsNullOrEmpty($roleName)))

            {

                $rdm_user_roles += $roleName

            }

        }

Write-Host $rdm_user_roles

Best Regards Lukas

1 - 3 of 3 items