Skip to main content
The 2024 Developer Survey results are live! See the results

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.

0 votes
1 answer
17 views

How to prevent the message "File open in another application" when creating excel instance

I was running a PowerShell script perfectly fine earlier, but for some reason this message popped up that's saying the file is open in another application. I have checked task manager and the excel ...
t0mas's user avatar
  • 1
0 votes
0 answers
13 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 &...
Craig's user avatar
  • 637
0 votes
0 answers
6 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 ...
José's user avatar
  • 1
1 vote
1 answer
17 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 "...
Vicky Dev's user avatar
  • 2,121
-2 votes
2 answers
36 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)] [...
Intolighter's user avatar
0 votes
0 answers
29 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 ...
sjanisz's user avatar
  • 97
0 votes
1 answer
20 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 ...
Gungun Tyagi's user avatar
1 vote
2 answers
49 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 ...
Billy Smith's user avatar
1 vote
2 answers
37 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-...
Abhishek-M's user avatar
0 votes
2 answers
53 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 $...
joseville's user avatar
  • 841
0 votes
0 answers
35 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-...
Owain Esau's user avatar
  • 1,892
0 votes
1 answer
50 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 ...
Peter Sun's user avatar
  • 1,727
-1 votes
1 answer
32 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: ...
Forgottenluv's user avatar
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 = &...
learner's user avatar
  • 835
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 ...
Von's user avatar
  • 1
-1 votes
0 answers
22 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 ...
Nexen's user avatar
  • 1
2 votes
1 answer
33 views

Winget ls shortening ids

I'm not sure if this is a winget question or a PowerShell question. Basically, winget ls output is too wide for the shell window, so it cuts off the column with ellipses. I tried ooutputing to a file ...
Nicolás Fernández Fioretti's user avatar
0 votes
1 answer
50 views

Powershell if function calling another function

I have 2 functions when I call the second function from the first one, always returns true doesn't matter if the second function has false return: function IsPodRunning($podName) { Write-Output &...
Alberto Serrano's user avatar
1 vote
3 answers
48 views

Powershell: add new line after every line that contains a given string

I have a >7000 line XML file, which I define as $File, and which contains (scattered throughout all the other lines) four lines exactly as follows: <text:p text:style-name="P27">&...
foolishgrunt's user avatar
-3 votes
0 answers
60 views

Cannot Download latest version of Chrome driver v126 or most latest via powershell command [closed]

Please correct my script if necessary: and please understand that I am new on this. Script # Define the destination folder $destinationFolder = "C:\Users\123\Downloads" # Create the ...
Barry Allen's user avatar
0 votes
1 answer
40 views

PowerShell: get data from a System.Collections.Generic.list [closed]

I'm struggling to get data from a generic list object in powershell. This is the output of my list object and I am trying to get the name value. {@{[email protected]; id=3; loginName=i:0#.f|...
Hens's user avatar
  • 1
0 votes
2 answers
29 views

Start a process in Jenkins without waiting for its end

I'm able to start a process in my Jenkins pipeline easily, but I'm struggling to avoid being blocked by the process. Currently, Jenkins is waiting for its end before going on to the next step, but I ...
lukemols's user avatar
0 votes
0 answers
40 views

How to launch an application in the second desktop using PowerShell cmdlet

I need to run a PowerShell script using PowerShell or some other means in another desktop without switching back and forth across desktops. I could not find any cmdlet or other way to accomplish this. ...
suresh prep's user avatar
0 votes
0 answers
18 views

How to add a reg file into Intune App Packager using Powershell?

Can anyone advise me on how I can add the below REG file to an MSI I wish to package on Intune using IntuneWinAppUtil? I understand that Powershell could be utilised, but I have never used it before ...
talksr's user avatar
  • 1
0 votes
0 answers
14 views

Changing User Rights Assingments From A Powershell Script [duplicate]

I am currently working on a project to make a script to get any computer CIS compliant up to IG3 level. Part of this includes changing the User Rights Assignments to only Admins or remote desktop ...
InfiniteWolf's user avatar
0 votes
1 answer
52 views

Azure DevOps AWS CLI with Powershell

I have a AWSShellScript task that executed a powershell script - example below trimmed for this post. -task: AWSShellScript@1 inputs: scriptType: inline inlineScript: 'pwsh -File test-script....
user1474992's user avatar
0 votes
1 answer
25 views

Power Shell script to automate need to install modules

Load required assemblies Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing function Show-MessageBox { param ( [string]$message, [string]$title ) [System....
Sekhar K's user avatar
-1 votes
0 answers
18 views

Automatically upload OneDrive files on log off/reboot

I am trying to set up automatic uploading of downloaded files to a user's OneDrive directory, at logout. When running my script at logout the OneDrive processes are already completed, I edit the ...
Stanislav Ilin's user avatar
1 vote
1 answer
39 views

Prevent system shutdown while task scheduler task is running

How can I create a task in Windows task scheduler that prevents (automatic) system reboots while it is running? I want the task to finish before any restarts are performed. Note: I'm aware that one ...
D.R.'s user avatar
  • 21k
0 votes
1 answer
45 views

Powershell: replace every line that contains a given string

Suppose I have a text file that contains the following lines: Apple Bananas Fruit things Oranges Fruit pieces I want to replace every line that contains the string "Fruit" with a new line ...
foolishgrunt's user avatar
0 votes
3 answers
73 views

How to separate dashes in IP ranges to build range

I have a list of IP addresses as follows (pulled from API): $IPs = @( 1.1.1.1-1.1.1.9, 5.5.5.1-5.5.5.3, 8.2.2.2-8.2.2.3 ) How can I separate these ranges so I can use a function I already have built ...
greenGob19's user avatar
0 votes
0 answers
56 views

Powershell - Invoke bat script and automatically type text at input prompts

I'm using EasyRSA-Start.bat OpenVPN script for generating clients. In cmd, after run, I have to type a command, after that I'm prompted to pass the verb, and I would next have to type exit to quit. I ...
david's user avatar
  • 180
0 votes
0 answers
22 views

Login-DataGatewayServiceAccount gets stuck within a script to query powerbi connections

I have got a powershell script that i will need to run as a service principal because that is how our automation scripts run. Currently when testing the script, I can run Login-...
learner's user avatar
  • 835
0 votes
0 answers
48 views

How to export the following PS into Excel sheet [closed]

Get-CimInstance -ClassName SoftwareLicensingProduct -computerName test,test2, test3| where PartialProductKey | select Pscomputername,Name,@{Name='LicenseStatus';Exp={ switch ($_....
Kourosh's user avatar
0 votes
1 answer
26 views

How to use Powershell to batch rename images to delete all of filename after the first space in existing name

Needing to rename a LOT of image files. Repeating names is not an issue as they were given numbers at the beginning of name and are all unique. What I need is to delete all the unnecessary mess after ...
Penny Lynn's user avatar
0 votes
0 answers
15 views

Access id denied error when using sendkeys command via task scheduler

I have a small script that works just fine locally, shown below. The script opens a media file and maximizes the window of whatever application opened it. if i am logged in and run it manually it ...
Arbelac's user avatar
  • 1,870
-1 votes
0 answers
20 views

Failed to download doctrine/inflector from dist [closed]

when I wrote (composer global require laravel/installer ) in windows terminal these errors appear Failed to download doctrine/inflector from dist: The zip extension and unzip/7z commands are both ...
programmer christina's user avatar
0 votes
1 answer
62 views

How to extract full monitor manufacturer/vendor ID in Windows? (as same as Linux hwinfo --monitor command)

I´m stuck with extracting hardware information of my monitor manufacturer ID in this format: xxxxx_xxxxxxx Basically, format which provides Linux command hwinfo --monitor as "vendor" ...
Zdeneik's user avatar
0 votes
0 answers
18 views

how to in powershell get icinga web 2 data

I have a script that gets the "icinga web 2" html page form This script was created by the firefox developer console. This script only works in powreshell when a firefox session is active. ...
exo's user avatar
  • 385
0 votes
0 answers
15 views

How to Bulk Remove References to a Malicious URL in Emails on Exchange/Office 365? [closed]

We recently discovered that a URL previously used by our organisation has been hijacked and is now hosting spam and possibly phishing content. This URL appears in the email signatures of many old ...
John Watt's user avatar
0 votes
0 answers
22 views

How to retrieve the output of CustomScriptExtension in Github

I'm trying to retrieve the output logs from a CustomScriptExtension in GitHub. The CustomScriptExtension executes a PowerShell script, and I want to make the output of this script visible directly in ...
Marab's user avatar
  • 39
1 vote
0 answers
19 views

windows shell -- running igblast: "BLAST query/options error: Germline annotation database ..."

I'm trying to run igblast from NCBI in windows powershell. When following the documentation and trying to run the following code: bin/igblastn -germline_db_V database/mouse_gl_V -germline_db_J ...
majahi's user avatar
  • 11
4 votes
3 answers
98 views

Create a string synopsis

Given a unknown string with an unknown size, e.g. a ScriptBlock expression or something like: $Text = @' LOREM IPSUM Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem ...
iRon's user avatar
  • 22.5k
0 votes
0 answers
22 views

Getting correct SignerInfos of a file via Powershell?

I am working on a Powershell-Sample to read all certificates and SignerInfos from a file. Below the code I have so far. It gives me all certs but only the first signer and this is in my case "the ...
Carsten's user avatar
  • 1,979
0 votes
0 answers
20 views

Teams and Sharepoint Reporting query in regards to Channels

Is it Possible to run a report that will show me the Size In storage quota that each Channel is set to across the whole of the estate of teams sites Thanks in advance i have been running the various ...
David Qaurmby's user avatar
0 votes
1 answer
61 views

I cannot extract .sql CREATE TABLEs for each table in my Azure SQL Database in my Azure Repo

Like the question says, how can I do that? This is the script I am currently using through the generation of a .dacpac file, but I've seen that this can be done with a PowerShell script instead of ...
WorkingProgrammer's user avatar
0 votes
0 answers
14 views

Unable to Export Server Certificate with Powershell

When attempting to set up an automated process to update the Octopus Deploy Certificate library with new certificates from our Servers. We are running in the following error message when trying to ...
Michael Huskey's user avatar
0 votes
0 answers
11 views

chaining execution in powershell and premature exit with non-zero code, kills vscode terminal

In vscode terminal (powershell), I was doing the following: & .\run-prog1.ps1 ; if($EXIT_CODE -ne 0) {echo "###failed"; exit 1; }; & .\run-prog2.ps1 In this case, run-prog1.ps1 ...
deostroll's user avatar
  • 11.8k
0 votes
0 answers
35 views

Why does csv consider data in one column to be an empty string

I have a powershell script, which basically takes an xlsx file with data, converts it to csv and then fills certain cells in another (template) xlsx file with values from certain columns. There are ...
Petr Synek's user avatar
0 votes
0 answers
18 views

How to get webViewLink of a file stored in my computer by Google Drive using PowerShell?

I would like to create a list of all files in a folder with its name and the webViewLink taken from the files sync'ed by Google Drive. I can get webViewLink for a particular file if I right click and ...
Sherry Camargo's user avatar

15 30 50 per page
1
2 3 4 5
2362