Stack Overflow » Powershell
196 FOLLOWERS
Stack Overflow empowers the world to develop technology through collective knowledge. This section of the forum is a place to ask question about Powershell.
Stack Overflow » Powershell
51m ago
I need to run some script using powershell on Windows Server 2016:
& $ScriptPath\Setup-Server -ConfigPath $SystemConfigPath -Role Servak
Once i run it, at some point i'm asking for the password twice which i need to enter manually (it's the same password). I want to avoid it and run the script using only command in powershell, without entering the password. I'm not concern about the security issues with that method.
How can i do it?
I need to type the password manually, which i want to avoid ..read more
Stack Overflow » Powershell
2h ago
In Windows 10 I was able to create a shortcut for running a PowerShell script and I could edit properties on that shortcut to manage the appearance of the console. I could set the font and font size, foreground and background colors (I need black text on a while background) and most importantly I could turn off output wrapping.
With Windows 11 it seems like Microsoft has forced a new combined command line and console, with global settings that can't be managed on a case by case basis. Is that true, or am I missing the new way to do this ..read more
Stack Overflow » Powershell
15h ago
I am using powershell to run this very annoying program that writes all of its progress output to STDERR. I want the output of this command to be both printed on to the console AND saved to a file.
First, I used this: COMMAND | tee compile.log. Everything looked good on the console, but the log file was empty. So, I tried this: COMMAND 2>&1 | tee compile.log. This caused the log file to be written properly, but it caused huge issues:
All output on the console was in the red error colour.
No matter if the command was successful, the exit code is erroneous.
So, is there something I can ..read more
Stack Overflow » Powershell
20h ago
Humbling seeking help. Beginner Powershell Core 7.4.2 scriptwriter. In reference to Get-Member results. My background is that I really prefer using Powershell Core's built in documentation rather than connecting to the internet or using an extension in an IDE. Here's an example of what I'm trying to do using just the Powershell Core
Get-Member cmdlet.
Example:
Get-Member -Name Trim -InputObject system.string[]
TypeName: System.String
Name MemberType Definition
---- ---------- ----------
Trim Method string Trim(), string Trim(char trimChar), string Trim(Params char[] trimCha…
My ques ..read more
Stack Overflow » Powershell
21h ago
I have a Powershell script that checks my network connection. If im connected to my domain - nothing happens. If im connected to a private network it starts my VPN app and establishes a connection. It its running hidden in the background.
I want to adapt the script so that it checks my network status all the time and put it in my Startup because im a lazy ass swine. You could call it "Fake always on VPN".
Now my question:
Is it better for CPU usage and all resources to perform the request about the network status every one or two seconds or as a loop?
Thanks in advance - greetings ..read more
Stack Overflow » Powershell
22h ago
Good afternoon. I am a novice programmer and Powershell user. I developed a very primitive hard coded program where I populate a form using simple commands like send Keys (enter, tab, up and down arrows )Etc.
The form consist of 15 web pages where you hit the next button and the next page loads. Each page load time varies between 15 to 45 seconds depending on the UT1 environment traffic. After selecting the next button, I hard-coded sleep commands between 15 and 45 seconds giving enough time for the page to load.
Is there a way I can make the flow and page loads more time efficient? I was thin ..read more
Stack Overflow » Powershell
22h ago
I want to deploy a long-running C#-executable to a Windows Server 2019 machine using Azure DevOps pipelines. The executable needs to run elevated and call an external application that cannot run in session 0. Thus the executable needs to run in an UI-session itself. I therefore use an interactive agent. Unfortunately the executable always closes whenever the pipeline-job finishes, but I need it to keep running.
The behaviour is reproducible using the following pipeline.
jobs:
- deployment:
environment: MyEnvironment.MyInteractiveAgent
strategy:
runOnce:
deploy:
steps ..read more
Stack Overflow » Powershell
1d ago
I have a windows computer and would like to gain ssh access to powershell from outside my home network. For this purpose, I opened a TCP port on my router and set up automatic forwarding to the computer I want to connect to.
Then, I created a rule in my firewall:
netsh advfirewall firewall add rule name="ps_ssh" dir=in action=allow protocol=TCP localport=<port_number>
Then I installed and enabled ssh in a powershell admin window:
Add-WindowsCapability -Online -Name OpenSSH.Server
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
Then I modified my %ProgramData ..read more
Stack Overflow » Powershell
1d ago
So all, I’m just looking for someone to help me across the finish line with a query.
I’m using the Graph API to query assigned licenses to users from Microsoft Entra.
So far, I can query a single user, and display the assigned licenses, but I’d like to output the information to a PSCustomObject, and that’s where I’m lost.
This bit of code queries the directory and returns all users
$GetUsersUrl = "https://graph.microsoft.com/beta/users"
$Data = Invoke-RestMethod -Uri $GetUsersUrl -Headers $Headers -Method Get
$Result = ($Data | select-object Value).Value
$Users = $Result | select DisplayName ..read more
Stack Overflow » Powershell
1d ago
Need to skip the first row in multiple CSV files. I am using the below Powershell code. But it is not giving the expected results.
Get-ChildItem -Path $CSVFolder -Filter *.csv | %{
Import-Csv $_.FullName | Select -Skip 1
} | Export-Csv $_.FullName -NoTypeInformation ..read more