Questions tagged [powershell]
PowerShell is a cross-platform command line and scripting utility from Microsoft. Use this tag for questions about writing and executing PowerShell scripts ONLY. Programming questions specific to the cross-platform version PowerShell Core (Windows, macOS, and Linux) should be tagged [powershell-core]. Questions about system administration should be asked on Super User or Server Fault.
powershell
108
questions
0
votes
0
answers
6
views
PS: Redirecting error output of assignment statement to a variable
I am calling PnP-GetWeb like this:
[Microsoft.SharePoint.Client.SecurableObject]$Web = Get-PnPWeb -Connection $pnpConnection -ErrorAction SilentlyContinue
if($null -eq $web) {
throw &...
0
votes
0
answers
5
views
Is it possible to run Connect-IPPSSession, Connect-ExchangeOnline using pwsh on a linux server?
I am trying to use the Powershell ExchangeOnlineManagement module, but I have to perform some automations on a Linux RedHat server and I would like to know if it is possible to execute commands like ...
0
votes
1
answer
13
views
Yarn PM not working in Windows when the User folder(UserProfile env var) has space in folder name or path
As stated in title, the Yarn PM(package manager), that I just installed in my system(Windows 11 64Bit) doesn't work if there's space(s) in my UserProfile folder path.
My User folder name is "...
-2
votes
2
answers
33
views
Is there a way to checkout latest version of origin branch without warnings [closed]
I wrote a powershell script to obtain git submodule and set his branch. It will run from pipeline and branch name will be passed from launch form input.
Param(
[Parameter(Mandatory=$false)]
[...
0
votes
0
answers
28
views
az cosmosdb update --ip-range-filter parameter either from file or powershell pipe
The az cosmosdb update command that I am using has exceeded length of 8192 characters so I am receiving "The command line is too long." error, the command itself looks following:
az cosmosdb ...
0
votes
1
answer
16
views
Failed to update help in windows powershell
I am an absolute beginner to Command Line Interface and noticed this when trying to update the help (I'm following Learn Enough Command Line to Be Dangerous, which I suppose is for Linux and I am ...
0
votes
2
answers
41
views
Place every item from a text file into an array but detect headers/titles
I have text files that contain
Firstname: xxx
Lastname: yyy
Login: abcd
It has many others entries for other definitions but all in the same format header: data
I would like to use an array in ...
0
votes
2
answers
30
views
Powershell : Cannot convert the "java" value of type "System.String" to type "System.Management.Automation.ScriptBlock"
I have a powershell script which converts the String and String[] into a BlockScript. It was working until now but it starts to fail suddenly after some windows upgrade.
function Invoke-...
0
votes
1
answer
46
views
How to make PowerShell `Select-String` aka `sls` output exact match(es) only?
In a PowerShell script, I would like to check if a branch exists locally already, which I'm currently doing as $existsInLocal = (git branch | sls $branch) -ne $null, but that's incorrect because sls $...
0
votes
0
answers
34
views
ps1 file wont run unless I change the encoding or add any character into the script
This is a weird issue, the scripts are coming from Intune deployed from patch my PC. On some devices when i try run these scripts they just hang and eventually timeout. If i convert the file to UTF-8-...
0
votes
1
answer
45
views
PowerShell StandardOutput Redirect Issue
I am trying to use ghostscript to get the number of pages in a PDF. I am getting this error:
Select-Object : Exception getting "StandardOutput": "StandardOut has not been redirected or ...
-1
votes
1
answer
28
views
How do I write a powershell function to send a warning if files don't exist?
I am new to powershell scripting and I am trying to create a function that sends a warning to my email if a list of files do not exist in my C: drive folder. The list of files I am looking for are:
...
0
votes
0
answers
10
views
401 (Unauthorized) Request Id when calling Get-DataGatewayCluster with a service principal
Currently trying to use a service principal in order to check power BI connection status
Connect-DataGatewayServiceAccount -ApplicationId $xx -ClientSecret $xx -Tenant "xx"
$scopeLevel = &...
0
votes
1
answer
40
views
Powershell - format info to csv
Trying to query non-windows native program (dell racadm) info and format string into csv file with other info. Everything works until I get to the iDracIP and it returns blank in the csv file. I ...
-1
votes
0
answers
20
views
How to pass docker commands through Powershell
Everyday i have to restart docker containers everyday. Don't ask. So i want to make Powershell script that connects through SSH to server with docker and then restarts all containers. So right now my ...