1,267 questions
1
vote
1
answer
136
views
How do I programmatically launch an application on a remote machine with PowerShell?
The following code will launch notepad.exe which can be seen in the processes. But it does not launch the notepad on the screen.
$wmi = [WMIClass]"\\REMOTE_MACHINE_NAME\root\cimv2:Win32_Process&...
1
vote
0
answers
98
views
How to setup a Remote PowerShell using WSManConnectionInfo in C# using Certificate Authentication?
I am trying to create a Remote PowerShell (RPS) that will form connection between machines to execute RPS Commands. I have this following example setup "HostPC with C# console application (that ...
0
votes
2
answers
211
views
How can I use Invoke-Command with WSMan in PowerShell 7 if "Powershell.7" endpoint does not exist?
I'm trying to run a remote command using Invoke-Command over WSMan in PowerShell on my local machine.
Here’s my test script:
$server = 'localhost'
Invoke-Command -Authentication Negotiate -...
2
votes
1
answer
106
views
How to setup a remote Powershell communication between devices using c# with Kerberos/Certificate?
I have this setup, I have a HostPC which will connect with say two remote PCs in order to run PowerShell commands. So, I will be using WSManConnectionInfo for this with HTTPS. I am just stuck around ...
1
vote
0
answers
53
views
Can't start a remote elevated PSSession to a stand alone host
We're developing a Windows application environment on EC2s. There is a Bastion host that will be used for configuration tasks using PSSessions to run scripts on remote machines. This was built in an ...
1
vote
1
answer
112
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
1
answer
64
views
I'm catching errors, why does output look like it isn't
Here's my PowerShell 5.1 script to get service status on all machines. I'm giving each server 5 seconds to respond before moving on. However, it still looks like I'm getting the uncaught messages in ...
0
votes
0
answers
77
views
How to redirect command output to different remoting session terminal into Windows Powershell (Terminal)
Normally I do it into an ssh session from Windows 10 Pro to my android/termux device ( that I am sure could be any linux Distro ) in the next way.
ssh to my devive (android/termux) like traditional ...
0
votes
0
answers
66
views
RunAsVirtualAccount for Register-PSSessionConfiguration
I am trying to create a remote session that allows me to execute windows updates and based on the other threads, creating a virtual session with -RunAasVirtualAccount is the way to go. I have ...
0
votes
1
answer
154
views
Java ProcessBuilder execute PowerShell Script as Admin
I have a Java application which is started with non admin rights.
From my Java application I want to start different PowerShell scripts. The PowerShell scrips have input and output parameter. Inside ...
0
votes
0
answers
82
views
Run a command in a specific Command Prompt window using its Process ID
Is there a way to run a command in a specific Command Prompt window using its Process ID?
$command = "C:\Windows\system32\cmd.exe"
$ID = (Start-Process -FilePath $Command -PassThru).Id
...
1
vote
1
answer
143
views
When capturing the return value of Invoke-Command I don't see the output of the commands
In a PowerShell script, I have something like this:
$Session = New-PSSession -ComputerName "WSEM00G2NZ" -Credential $credObject
Invoke-Command -Session $Session -Scriptblock {
python ...
0
votes
1
answer
343
views
Azure Release Pipeline - Execute a PowerShell script from a remote server
I need to create a release pipeline for coping two .dll files and remotely execute a PowerShell script.
What I did,
Wrote a bash script to download the .dll file and PowerShell script file from ...
-1
votes
1
answer
258
views
Run Powershell scripts from Linux machine
I have some PowerShell scripts, which remotely collect some info form Windows machines via WMI and then return result in JSON format. Now, for these goal i have windows machine, which has all my ...
1
vote
2
answers
119
views
Error calling Get-ChildItem from Invoke-Command
In this scenario, there two servers. We'll call them ServerA and ServerB. There is also network share: \\share-ip-address\hidden_share$.
I am using the following Powershell command to get the most ...
0
votes
2
answers
926
views
List all WinRM listeners with property support
winrm e winrm/config/listener
Will list all listener, but displayed in string format. Like this :
Listener
Address = *
Transport = HTTPS
Port = 5986
Hostname
Enabled = true
...
0
votes
0
answers
88
views
How to execute remote PS script independently
Let imagine there is a PowerShell script already there in a remote computer and let that script composed of 8 lines. When I try to run that script from my local computer by using “Invoke-Command”, all ...
1
vote
1
answer
80
views
Can I connect a PSSession to a VM with no password?
I have a VM with no password that I want to connect to using PSSessions, but it fails if I try to provide an empty password:
> $s = New-PSSession -VMName "vm-240404"
cmdlet New-PSSession ...
0
votes
0
answers
132
views
PowerShell Start-Process in Invoke Command doesn't work correctly [duplicate]
I have a problem with PowerShell. Main goal is to run an exe (developed by me) on a remote machine.
start-process in Invoke the command run related an exe. But its closed immediately by something. It ...
1
vote
2
answers
227
views
Run script as admin on remote using PowerShell
I am trying to run a script on remote using PowerShell. The script starts a service and works perfectly when I execute it using RDP. I try
PS C:\Users\me> Invoke-Command -ComputerName '123.123.123....
0
votes
1
answer
360
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 &...
2
votes
1
answer
65
views
What am I not understanding about sorting this list [closed]
I'm trying to sort my list but it's not sorting as expected. Why is this?
Invoke-Command -ComputerName $computers {
$rscontent = Get-Item C:\temp\file1.txt | Sort-Object LastWriteTime -Descending ...
0
votes
1
answer
348
views
Why can't I run accesschk using a PowerShell remote session to check system permissions?
I'm trying to get the system security permission for a specific user on a remote system using SysInternals AccessChk.
If I login to a computer as adminstrator, copy SysInternals tools to my ...
1
vote
1
answer
40
views
How can I make any errors thrown go thru the else part of my condition?
Given: PowerShell 5.1
I'm getting an "Access denied" for some of the the computers in the array. How can make any errors run through the "else" part of condition where it's NOT ...
0
votes
1
answer
447
views
How do I: Delete old Certificates windows servers using Powershell (Azure Classic Release Pipelines)
How do I: Delete old Certificates windows servers using Power Shell (Azure Classic Release Pipelines)
Tried this code and I get:
2024-05-07T02:43:20.4279860Z ##[error]Atleast one remote job failed. ...
0
votes
0
answers
52
views
While connecting to a remote machine with New-PSSession command -OpenTimeout option not working
I am trying to implement a script, which connects to a remote windows machine via winRM. For that, I am using New-PSSession command. But, there are some machines for which this command takes more than ...
1
vote
0
answers
23
views
WildCard Certificate appears to be installed but not installed in reality
I am new to Powershell. But I put up this script by getting info from multiple SO threads and google search. I am trying to install wildcard certs on multiple servers in one go using below script.
$...
1
vote
0
answers
170
views
How do I check whether directory exists on remote computer/DFS share, and create it if not?
The script is to be run from a central administration server.
I need to check if a directory (BA Client) exists on multiple remote computers.
If it exists, I then need to check if it exists on a DFS ...
1
vote
2
answers
151
views
Powershell sorting data in Invoke-Command results
I'm running an exe from invoke-command on multiple servers and it works. I get a string array with all the output I expect.
$result = invoke-command $servers { & "\path\toexe" arg1 }
...
2
votes
2
answers
262
views
How to pass an Object in a ScriptBlock instead of a single variable?
I am trying to get a Powershell script working where one of my ScriptBlock commands requires an Object as a parameter, rather than a single variable. Example:
Invoke-Command -Computername "...
0
votes
0
answers
620
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-...
2
votes
1
answer
211
views
Variable not defined when trying to list a group of AD user from a CSV using Get-ADUser -Filter {displayName
I am using the below code to try and pull out a list of last logon times for a group of users contained in a CSV file. I have a test domain at home and the script below works fine. However, when I ...
0
votes
2
answers
120
views
How do I define hash tables with protected values using the VariableDefinitions section in PowerShell JEA session configuration files?
When defining "private global" variables to be used with functions and scripts in JEA sessions using New-PSSessionConfigurationFile, I noticed that I'm only able to create string variables.
...
1
vote
1
answer
186
views
Get-InstalledModule Command Not Working Remotely
There seems to be some issue with the PowerShell Command Get-InstalledModule.
E.g When I log in locally to a Windows server (PowerShell 5.1) and execute command Get-InstalledModule -Name Az it works ...
1
vote
1
answer
737
views
User permits on cmdkey to execute remotely
Ive made an script to re-add credentials on windows, the script locally works fine, but when i try to execute via Invoke-Command the script just executes itself and does nothing or via Enter-Pssesion ...
1
vote
2
answers
2k
views
How do I remotely reset the WinRM service using PowerShell?
When re-registering a configured PowerShell session with the same name as before, the WinRM service might (more often than not) need to be restarted.
My issue is that this needs to be done remotely in ...
0
votes
0
answers
121
views
Can I have a PowerShell SessionConfiguration to be accessed by only one of the ports setup with WinRM?
I've been working with JEA (Jest Enough Administration) in PowerShell recently and would like the JEA sessions to only use a specific non-standard TCP-port.
I'm able to configure the WinRM service to ...
0
votes
1
answer
181
views
How do I use VariableDefintions in a PowerShell interactive JEA session?
I've been trying to define variables for a PowerShell JEA session in configuration files using VariableDefintions.
However, access to the defined variables is denied. All other configurations with ...
1
vote
1
answer
361
views
Passing admin credentials in Start-Process cmdlet
I am trying to build a script that installs an application with encrypted local admin credentials on the pc when the user logged in is not an admin.
I am running the below cmdlet:
$User = "admin@...
0
votes
0
answers
165
views
How to connect to VPN using PowerShell native cmdlet
Every answer on here is using rasdial. Is there another way to do it? My VPN credentials are already saved so hopefully just the name of the VPN and that's it.
Something like, Start-VPN -Name "...
2
votes
1
answer
402
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
329
views
AWS SDK can't find default credentials when using remote Powershell via WinRM unless user has logged in manually
I'm having a very odd issue. I have two Windows servers (2022 Datacenter). ServerA and ServerB. As part of an automated deployment process ServerA uses a remote (WinRM) Powershell session into ServerB ...
2
votes
1
answer
842
views
Get-Service fails but Invoke-Command {Get-Service} succeeds
I'm trying to run a series of PowerSHell commands on my desktop computer that connect to one of the corporate servers and checks on the status of the services there. I'm doing a Run As on the ...
0
votes
1
answer
103
views
I'm trying to run this script with remote powershell sessions on multiple computers, but it's not working
I have a very simple script that I would like to run on multiple computers with remote powershell. I'm currently I'm using it on my company's GUI based remote powershell solution for a single computer ...
0
votes
1
answer
47
views
Separate values of two properties into dynamic excel columns and remove duplicates
I am creating an inventory script for my team and the end goal is to gather monitor information of multiple computers provided from a list. The output results in an excel sheet with a table.
My ...
1
vote
1
answer
237
views
Unable to Launch or Execute New Window or Applications on Remote System Using Windows PowerShell "Invoke-Command"
In Windows Powershell (admin):
Connect to Remote Windows
$session = New-PSSession -ComputerName "xx.xx.xx.xx"
Attempting Remote Execution
Invoke-Command -Session $session -ScriptBlock {
...
0
votes
1
answer
760
views
Getting error "Copy-Item : Cannot find path 'S:\' because it does not exist." while trying to copy file from Azure VM
I'm trying to copy file from one directory on Azure VM to other located outside of VM. I created a script to cover that:
[pscredential]$credObject = New-Object System.Management.Automation....
1
vote
1
answer
925
views
Trying to create a powershell script to install a program on a remote computer on the same network
I'm very new to Powershell and I am trying to create a script whereby I copy a folder from one computer to another computer on the same network, and then run a batch file as an admin on the remote ...
2
votes
1
answer
3k
views
Run RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry remotely for Printer Settings Update
I have admin for same account on 2 Windows 2016 servers. Server1 has this folder\file: 'E:\Temp\ZEBRA_1.dat'
If I open PowerShell (v4 or v5) (as admin) on Server1 and run this line of code everything ...
1
vote
1
answer
1k
views
Powershell script to extract a list of servers/computers from a .txt file and then display status and then export to CSV?
I have a list of 140 servers in a txt file and need to check status of Crowdstrike on each of them and then export to CSV. Would the below be correct?
$Computers = Get-Content -Path C:\temp\servers....