Re: Use Remote command execution to play a script (252 Views)
Reply
Occasional Visitor
greglbn
Posts: 3
Registered: ‎07-23-2013
Message 1 of 4 (334 Views)

Use Remote command execution to play a script

Hi,

 

I try to use Remote command execution to play a powershell script on the remote serveur.

I hace test to play a simple command like cmd /c dir and it work, but i don't know how to play a complete powershell script like this one directly via hp oo, without coping it to the remote serveur:

 

Param (
[String]$partition
)

Clear-Host

# Fonction de treesize de niveau 1
function Get-FolderSize ($_ = (get-item .)) {
Process {
$ErrorActionPreference = "SilentlyContinue"
$length = (Get-ChildItem $_.fullname -Recurse | Measure-Object -Property Length -Sum).Sum
$obj = New-Object PSObject
$obj | Add-Member NoteProperty Name ($_.Name)
$obj | Add-Member NoteProperty Length ("{0,13:N2}" -f ($length / 1MB))
return $obj
}
}

# Définition du volume en fonction de la lettre de partition
$volume = $partition + ':\'

# Renvoi des valeurs par répertoire
Get-ChildItem $volume | Get-FolderSize

 

Does anyone have the solution ?

 

Best regard's

Grégory

Trusted Contributor
Steve_Drummond
Posts: 89
Registered: ‎10-01-2012
Message 2 of 4 (316 Views)

Re: Use Remote command execution to play a script

Does the operation /lib/Powershell/Powershell Script suit your needs? this operation has gone through several improvements in content packs so could be different (I'm using CP 11).

 

Alternatively you could write the script at run time on the server and execute it with RCE via "powershell <file.ps1>"

Occasional Visitor
greglbn
Posts: 3
Registered: ‎07-23-2013
Message 3 of 4 (311 Views)

Re: Use Remote command execution to play a script

Hi,

 

It's what i have done a flow wich copy the source to a file, copy the file to the target, use remote command to execute end then delete the file.

 

But i want to know if there is another solution using remote command execution ?

 

Best regard's

Grégory

Occasional Contributor
Ankit_1985
Posts: 3
Registered: ‎12-06-2013
Message 4 of 4 (252 Views)

Re: Use Remote command execution to play a script

Hello Georgy,

 

Could you please let me know, how u are doing it..

 

I am struglling to run the command itself on remote server.

 

Few doubts:

1. During file copying , can i do password less copying.

2. To execute a command on windows or unix, do i need to pass userid and password to that target server?

 

Thanks,

Ankit

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.