576 questions
2
votes
1
answer
76
views
Invoke-Command remote script behaviour on Server 2016 vs 2025
I have an existing script which has worked for some time running on a Windows Server 2016 server, but which gives me an error when run on its relacement 2025 server. What is strange is the error doesn'...
1
vote
1
answer
105
views
In PowerShell, I cannot transfer System.Data.DataTable using the invoke-command to the remote host
Here is a script in which I am trying to pass a variable of type System.Data.DataTable via invoke-command to the remote host:
function Test1 {
param (
[System.Data.DataTable]
$...
1
vote
2
answers
90
views
Invoke-Command and/or Start-Process fail if no user session is active on the remote system
tl;dr
If I locally start Invoke-Command to start an EXE file remotely, it fails, if there is no active user session on the remote system.
I am facing the challenge of installing an application with ...
1
vote
2
answers
108
views
Powershell Invoke-command works but returning an exception
My script opens a WebDAV session to my server, but on some occasions the command is stuck, without any exception.
The command is $Session.Open($SessionOptions).
To monitor the command with a timeout, ...
1
vote
1
answer
125
views
PowerShell: executing C# Class (FindFiles) as an Add-Type definition on a remote system using Invoke-Command is extremely slow
I want to find all Package.json files on a remote system using PowerShell. In order to optimize this, I found a C# class on the internet adjusted it and now would like to use it.
This code runs really ...
0
votes
3
answers
173
views
Issue "Invoke-Command & Get-Content with large files"
this is my first post because i can't find a solution and i don't understand whats wrong...
I have a simple script which should read a large logfile on a client with get-content in an invoke-command.
$...
0
votes
1
answer
105
views
Powershell invoke-command: why isn't this engaging the foreach loop? [duplicate]
OK, I'm piggybacking off my previous question Powershell script to get IIS app pool recycling time from servers and wondering what I'm doing wrong
I have a list of IIS app pools (apppools.txt) and a ...
0
votes
1
answer
186
views
Use Invoke-Command create new user with secure password on remote client
I am struggling to resolve what should be a simple thing.
I am looping through a list of computers $bcs for each $bc in $bcs.
I run the command below to remotely create the user account with the ...
1
vote
0
answers
31
views
Error using Powershell's Invoke-Command with Filepath [duplicate]
I have a Powershell script 'hello-world.ps1', which is overly simple, it takes no arguments and simply writes some text to the console:
Write-Host "Hello world"
With the command prompt, ...
2
votes
2
answers
81
views
Why do I get access denied using Invoke-Command on localhost?
I have valid credentials of a Windows service account stored in $creds and want to use them to access the C:\temp\ directory on another server called remotehost. I use Invoke-Command to execute the ...
1
vote
0
answers
1k
views
Executing sfc.exe /scannow on Remote Computer Using PowerShell Doesn't Show Process
I'm attempting to run sfc.exe /scannow on a remote computer using PowerShell's Start-Process, but I'm unable to confirm whether the process starts on the remote machine. When I check for any sfc ...
-1
votes
1
answer
255
views
Understanding PowerShell SessionOption OperationTimeout Behavior with Invoke-Command
I've set the OperationTimeout to 10 seconds, but when I run a command that sleeps for 20 seconds inside an Invoke-Command block on a remote computer, I don't get an error. Here's the code:
$...
0
votes
1
answer
344
views
Efficiently Retrieving Microsoft Edge Versions from Multiple Remote Machines Using PowerShell Jobs
$command = {
try {
$package = Get-Package -Name "*Microsoft Edge*"
return [PSCustomObject]@{Version = $package.Version}
} catch {
return &...
0
votes
2
answers
360
views
How to get return value of Invoke-Expression in Powershell
So this is my code
$result = Invoke-Command -Session $session -FilePath $ps1
How do I get the result given by $ps1?
The code of that function is supposed to give a true false result like in the ...
1
vote
1
answer
2k
views
When using invoke-command with credentials, credential parameter not properly initialized
So I tried calling the following code with and without credentials.
$username = "user"
$password = "password"
$cred = new-object -argumentlist $username, $password
#Invoke-Command ...