576 questions
2
votes
1
answer
86
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
2
answers
97
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
1
answer
128
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
1
answer
108
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 ...
1
vote
0
answers
32
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, ...
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 ...
0
votes
1
answer
351
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 &...
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 ...
0
votes
1
answer
140
views
In Azure Runbook - map a drive to remote server
I have a working PS Script to run in an Azure Runbook to map a drive to a remote server to then copy very specific files to Azure blob storage.
NOTE: The entire script works 100% in VSCode > ...
1
vote
0
answers
165
views
Invoke-command works only when any user is logged (msi install)
I've got a problem with running Invoke-Command on remote Computer with WinRM up and running. I've configured and run WinRM, but Invoke-Command with task of Silent Install is not successfully run until ...
-1
votes
1
answer
447
views
Start-Process is not working in Invoke-Command
$upgradeInvoke = Invoke-Command -Session $session -ScriptBlock {
try {
Shutdown.exe /r /f /t 1200 /d p:4:2 /c "Triggerd Reboot Timer for 20 minitus"
$...
0
votes
0
answers
596
views
get-acl access property is just System.Security.AccessControl.FileSystemAccessRule when run inside invoke-command
I'm tying to get the permissions of all the folders in a path on a remote server as efficiently as I can so I want to make as few calls as I can (avoiding looping through all folders and running a get-...
1
vote
1
answer
2k
views
Execute Start-Process Powershell Script on a Remote Computer
I open PowerShell as admin and use the following line of code to run an offline file for windows updates. It works fine
Start-Process 'wusa.exe' -ArgumentList 'C:\Temp\windows10.0-kb5032189-...
2
votes
1
answer
397
views
How to error handle Invoke-Command over SSH
I'm currently working with a script that utilizes the Invoke-Command over SSH as shown below. While it works well, I'm looking to implement exception handling, specifically for scenarios where the ...
0
votes
0
answers
83
views
I'm having issues trying to remotely install certificates on a list of servers using PowerShell
I've been tasked with updating some certificates on some remote servers. We have a TON of servers and not all of them have these certs installed.
To make a short story long....
There are 2 different ...
0
votes
1
answer
362
views
How can I call a Function, inside of a Function, inside of Invoke-Command ScriptBlock?
I have been racking my brain over this and scouring the internet for an answer, but I can't seem to find anything for my specific situation. I have created a set of Functions that help me add/remove ...
0
votes
1
answer
849
views
Using global Variable in Invoke-Command
I am trying to figure out a way to use a global variable in a Invoke-Command without success.
There are some posts which I tried but they do not work in this use-case.
So what I have is a script like ...
0
votes
1
answer
426
views
run .exe as administrator on a vm with Invoke-VMScript Powershell 7
I need to be able to launch command by shell console or powershell having the administrator window in powershell 7.
I have launched several commands with Start-Process but none of them returned the ...
0
votes
1
answer
76
views
Throwing null error when trying to rename directory via Invoke-Command in Powershell [duplicate]
I'm basically writing a program that takes an input of a current folder path from a user and a new folder path that they want to rename it as. Then the program remotes into a file server that the ...
0
votes
1
answer
148
views
Powershell invoke-command returns one object property only
I try to get Windows audit policies on several Windows servers with an Invoke-Command cmdlet. It works fine for all servers, except one where I get only the first object property (the added ...
0
votes
1
answer
62
views
How to save a table to a log file without replacing the information
I am trying to get a shadow storage information from remote computers.
I could get the information and store in a variable as table.
But every time the log file is being overwrite by the new ...
3
votes
1
answer
233
views
Powershell Invoke Command Export to Excel
Having a few issues with this PowerShell code:
$vmslist = Import-Csv -Path .\vmsList.csv -Delimiter ',' | ForEach-Object {
$_.Servers
$vms = [string]$env:COMPUTERNAME
$currentVms = $_....
0
votes
1
answer
297
views
Running a bat script with invoke-command works on vm:s but not on physical machines
I try to run an oracle bat script (opatch.bat) remotely to gather info on patchlevels on oracle agent installations.
The command to run is
invoke-command -ComputerName <remote_computer> -...
0
votes
2
answers
635
views
Invite Users to Azure DevOps Project via REST API (PowerShell)
The goal of the script is to invite a user to a specific project in Azure DevOps via REST. Invoke Request was used to add a user with the appropriate permissions.
I'm able to successfully retrieve the ...
1
vote
1
answer
5k
views
Run Powershell Script as Administrator remotely
Script_A.ps1 on Server A:
Invoke-Command -ComputerName Server B -ScriptBlock{
Set-Location "C:\Path"
.\Script_B.ps1
}
The Script "Script_B.ps1":
Set-Location "C:\...