Author Posts

November 21, 2013 at 2:14 am

Hello guys
Could You advise please.
I run script (find big old files on big FTP) via RDP. Logging in, run script and waiting (for hours, coz ftp is big)
sometime RDP breaks down, i reconnect and lose my posh window and all results of unfinished job

Could you please advise me the right way of doing this job
remote launches are forbitten by sysadmin((

Regards

November 21, 2013 at 10:00 am

Just so I am sure I understand, are you saying you are forbidden (by group policy) from double-clicking the ps1 file to execute the script you want to run?

If so, is it possible for you to test the following:

Try to remote to the computer
Open the powershell ISE on it
Paste in the script you want to run (Making sure you export the results to a file on that computer)
Click the run button
Close the RDP window
RDP to the target computer later on (when you know the script should be complete)
Copy the results file from the remote computer to yours (so you can review it)

I just did that on a spare computer here at work and it works fine.

Get-ChildItem c:\ -Recurse | Where-Object { $_.LastWriteTime -lt "11/22/2007" -and $_.length -gt '500,000,000'} | select fullname,length,LastWriteTime | export-csv c:\outputfiles\testout.csv

That seems to work fine, even if I kick off the script then immediately close my RDP connection to the remote computer.

November 21, 2013 at 10:29 am

So you're saying that PowerShell remoting is not allowed in your environment? (If so, in a perfect world you could just educate whoever made that policy. PowerShell Remoting is the future of Windows administration; DCOM and RPC are being gradually phased out in favor of WinRM.)

If your server is running PowerShell 3.0 or later, you can use a PowerShell Scheduled Job. This avoids remoting, but still allows you to come back to it later and retrieve the results (even if your current session gets closed.) See this link for more information.

November 22, 2013 at 1:46 am

Many thanks for answers
i will try case with ISE (just change lenght with @{name='Size(MB)'; expression={[int]($_.Length/1MB)}}) – so it will be more readable
yes. our senjor admin rejected my request about PSRemoting, so i need to execute scripts being connected via RDP

regards

November 22, 2013 at 8:18 am

[quote=11609]So you’re saying that PowerShell remoting is not allowed in your environment? (If so, in a perfect world you could just educate whoever made that policy. PowerShell Remoting is the future of Windows administration; DCOM and RPC are being gradually phased out in favor of WinRM.)

If your server is running PowerShell 3.0 or later, you can use a PowerShell Scheduled Job. This avoids remoting, but still allows you to come back to it later and retrieve the results (even if your current session gets closed.) See this link for more information.

[/quote]

Yegor isn't the only one who suffers from management with poor understanding of what powershell can do for an IT environment.

I too work in an environment where I not only can't use powershell remoting, I can't even have Admin rights on my OU. Yet I am expected to manage over 5000 computer and user accounts...go figure.