how I can run this command in powershell to all users in the server?
powerShell -sta -file 'E:\Script-Popup\Popup-Message - Done.ps1'
that on every user who is currently connected to the server, this command will run.
how I can run this command in powershell to all users in the server?
powerShell -sta -file 'E:\Script-Popup\Popup-Message - Done.ps1'
that on every user who is currently connected to the server, this command will run.
Option 1:
Get connected users:
query user /server:SERVERNAME
For each user run:
$username = "username"
$password = "password"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $username,
$securePassword
Start-Process powershell.exe -Credential $credential -ArgumentList "-file
$script"
Option 2:
Configure a logon script using a GPO (the script will run when the users login)
You don't need PowerShell for that (but you can use it with PowerShell)
msg * 'This will be shown to all users as a pop up'