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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
3 views

Adding new VM IP Address to Azure Gateway Backend Pool failin

I'm trying to automate the inclusion of an IP Address of a new VM I am creating with an ARM template into an Azure Application Gateway Backend pool. From what I can gather, I need to get the current ...
Micksta's user avatar
  • 23
0 votes
0 answers
14 views

Cannot use Get-MgUser with directory.readwrite.all Graph permission

we have an application published on our partner tenant with directory.readwrite.all permissions granted (both delegated and application), that app has been pushed out to all of our client tenants ...
phoneybaloneypshell's user avatar
-1 votes
0 answers
9 views

How can I create pipeline variables in Azure DevOps using PowerShell script?

I already have an existing piece of code that I use to create release pipelines in Azure DevOps. I am looking to refine it to create pipeline variables that are settablea t release time. Couldn't get ...
Enig's user avatar
  • 1
0 votes
0 answers
23 views

Windows Powershell thinks Desktop does not exist

I need to change directories. However, when I run the command, the Powershell throws an error, saying it could not find the path because it does not exist. Here is the error thrown when I run the ...
ultraCodingNoob456's user avatar
0 votes
0 answers
14 views

PowerShell error passing a variable in Test-Path command. Cannot bind argument to parameter 'Path' because it is an empty string [duplicate]

Below is the code I'm trying to run. I had this work one time before but now it says the string is null. If I pass the entire string path into the command it works, but it will not work with the ...
John's user avatar
  • 1
0 votes
0 answers
7 views

Login with Powershell to website, cant find the right fields

Im struggling logging in to a website. I cant find with the Google Chrome Developer Tools the Names of the FIelds of the Form. I did find the form "bs-dummy-login-form" with the following ...
Alex's user avatar
  • 49
0 votes
0 answers
16 views

Create reviewers for environments in github repository using github api

The below powershell works and helps create environment test_mont under repo testDevOps $owner = "mybank" $repo = "testDevOps" $envName = "test_mont" # The name of the ...
Ashar's user avatar
  • 2,942
1 vote
1 answer
21 views

Edit Single Line XML File In PowerShell Without Changing to Multi-Line XML File

I have a HUGE XML file that has a whole ton of data packed into a single line. I've found when I edit that file with PowerShell, it breaks all of the data up into individual lines instead of a single ...
Christopher Cass's user avatar
0 votes
1 answer
14 views

The specified mailbox Identity:username doesn't exist

running into a bit of a problem here. First, Powershell is running elevated and connected to EXOL with a global admin account. If I use 'get-mailbox username' it will return the user mailbox info. If ...
nosupport2020's user avatar
1 vote
1 answer
27 views

How could I write a script which populates a CSV column with all filenames from a path?

I would like to get all items in a path with Get-ChildItem, then with regex, match everything in the filename before the '@' (andrea.figuera@gmail.com.pst), and capitalize the first letter and the ...
Nick's user avatar
  • 21
0 votes
0 answers
22 views

sqlcmd.exe works locally but not through azure pipelines

I am attempting to get an old script running in azure pipelines, the script is quite old but it works great when ran locally. However, when I execute the script through Azure Pipelines it comes back ...
Lucas's user avatar
  • 376
1 vote
1 answer
17 views

How can I pass variables into a Powershell ObjectEvent action

I'm writing a tool which will take an action whenever a new file is written into a folder on a windows server. I'm using the following $action = { write-host "action fired" Process-file $...
Ian's user avatar
  • 267
0 votes
0 answers
12 views

how to get the last windows update dates in VCenter

I would like to write a script and then automate it to check weekly the Windows updates of VMs in Vcenter and note the date, if a machine has not update Windows for more than 90 days, send a mail. ...
kaiwen Shao's user avatar
1 vote
2 answers
26 views

AWS CLI query S3 bucket names

I am using this command in PowerShell to list all buckets in my account: aws s3 ls --profile xxx-dev I need to list only the buckets that starts with some string. I tried this: aws s3 ls --query "...
rbasniak's user avatar
  • 4,526
0 votes
1 answer
27 views

Trying to convert XML file into CSV in PowerShell results in an error

Trying to run a PowerShell script, as follows, I am presented with the error message "Cannot bind argument to parameter 'InputObject' because it is null.". The script is - [XML]$inputFile = ...
europtaifun's user avatar
-6 votes
0 answers
18 views

Task scheduler mail alert. help me with this [closed]

We have a powershell script running with the help of task scheduler, we want an email alert when ever the task is failed or stopped.how can i achieve this using task scheduler or may be someother ...
Satya Reddy's user avatar
0 votes
0 answers
13 views

Pass variable as a param of a ExO PowerShell cmdlet New-ManagementRole

I am trying to automate new management role creation via a PowerShell script and I am using -EnabledCmdlets to create the management role with access to only required PowerShell cmdlets. New-...
Yasitha's user avatar
  • 2,233
0 votes
2 answers
30 views

Skip Record and Move On to the Next In PowerShell ForEach Loop

I have the following PowerShell code that queries a SQL database. If the number of results from the query is not 0, for each result, the First/Only Design Number is added to the FirstOnlyDesignNumbers ...
Robert Gething's user avatar
0 votes
0 answers
35 views

Can't open bin.file in terminal in Window 10 [closed]

I'm working on an assignment that involves using the "read_cadu" code to process binary files and convert them into stdin. The code originally used #include <arpa/inet.h>, but I needed ...
Daniel's user avatar
  • 1
1 vote
1 answer
47 views

Why does my environment variable affect the execution of an SQL query?

I am learning Powershell by my own and I am trying to keep the best practices in my learning process. I am using a database.env file with some key value pair configuration lines, if I use it I present ...
Ronald Jimenez's user avatar
-2 votes
0 answers
22 views

Python script to convert JSON to multiple CSV files with additional processing [closed]

I have a large nested JSON file which I need to convert to three different CSV files. The complications is that there is some work needs to be done before export occurs. Here is the JSON sample: [ ...
DenJS's user avatar
  • 21
1 vote
1 answer
37 views

How can i declare a multi dimensional array in Powershell?

I have an array as follows: $apps = @('app1', 'app1a', 'app1b', 'app2', 'app2a', 'app2b') Now app1 , app1a and app1b are all related, so I want them in one item in the array and able to access: I ...
Traci's user avatar
  • 49
0 votes
0 answers
12 views

Execute a Batch and Powershell Script on a Remote File Server [migrated]

I'm telling you that I'm trying to figure out how to run a PowerShell script without having it stored on the computer. simply running it with some jse script and let the script know where the file is ...
brenda gomez's user avatar
1 vote
1 answer
39 views

Adding alias properties (AliasProperty members)

I just wonder why this works: $s = "hi there" $s = Add-Member -InputObject $s -MemberType AliasProperty -Name Length2 -Value Length -PassThru $s | gm -MemberType AliasProperty #the property ...
Purclot's user avatar
  • 495
0 votes
1 answer
58 views

MSOnline #Powershell

**When I run this script ** $Uppn = "XXX@ms.XX.XX"` $UserID = "00000" $DisName = "XXX XXXX " $FirstNm = "XXXX " $LastNm = "XXXX " ...
Tuwan Jaleel's user avatar
1 vote
1 answer
40 views

How to get key and value pairs from converted JSON file

I converted in PowerShell a JSON file into a variable. $JSON = Get-Content -Path "$LogFile" -Raw | ConvertFrom-Json Sample (Object): Id : Directory_825efe20-2c90-4b90-885f-...
user3022917's user avatar
1 vote
1 answer
18 views

Can Pester v5 Mock command be called outside an It, Before or After block?

I have some old Pester v4 tests that are failing when I try to run them in Pester v5. With Pester v4 I read that once Mock is called it will continue to apply for the rest of the Describe block, even ...
Simon Elms's user avatar
  • 17.9k
1 vote
1 answer
36 views

Unable to attach images on the message body powershell send email

Pleae assist, I'm tring to send email with screenshoots on the message body but i keep getting an error. Images do exist in the folder. Any advise or guidance will be higly appriciated. Thanks in ...
Lucky Nthite's user avatar
0 votes
1 answer
21 views

Windows: List shares and permissions using Powershell

I have a Windows2012R2 server with many shares. Each share has assigned some groups for granting permissions, for example: Share.................................| Groups.................................
Spacewalker's user avatar
1 vote
0 answers
29 views

Git alias with positional parameters in PowerShell

I have a following git alias command: git config --global alias.deploy '!f() { git push origin $(git rev-parse --abbrev-ref HEAD):env/$1; unset -f f; }; f' And it works on Linux: when I execute git ...
rfg's user avatar
  • 1,556
0 votes
2 answers
41 views

Summarize/Parallelize a (recursively) rename task in powershell

I have to rename a big bunch of files and replace text in filenames like a1 to a2 and b1 to b2 etc... Because it's a very large amount of files I want to summarize/parallelize/replace several texts at ...
WOEWE's user avatar
  • 1
0 votes
0 answers
14 views

Piping commands to psftp on powershell

I am trying to use psftp through piping commands to stdin. (echo "cd /tmp/transfer/ && put D:/File.txt /tmp/transfer/" ) | D:\psftp.exe user1@hostname -pw ******-v -bc -batch Remote ...
Maven's user avatar
  • 14.6k
0 votes
1 answer
23 views

Only a single command in "Get-Command -Module SqlServer" of "Invoke-SqlNotebook". How to get the rest?

I want to run Invoke-Sqlcmd but it's not found on my Windows 11 system For some reason the only result is "Invoke-SqlNotebook" I've removed, installed, imported, updated SqlServer module Ran ...
andrewjamesbowen's user avatar
0 votes
1 answer
58 views

How to Assign Microsoft Graph API Permissions to a User Assigned Managed Identity?

I have a user assigned managed identity that's associated with VM resource and I want to assign several Graph API permissions to. Most everything I find online is uses a system assigned identity. When ...
bmkaiser's user avatar
0 votes
0 answers
30 views

Powershell how to kill a particular program when the script window is closed? [duplicate]

I want to start two python programs via a powershell script, and then close them when the powershell script exits by closing the terminal or window in which the script is running. So far my tried ...
Danyaal Majid's user avatar
3 votes
1 answer
44 views

PowerShell: List of all successful logins to the system

Helo,, How can I read a list of all successful logins on the server via Powershell? The following fields should be output in the list: TimeGenerated, UserName. I'm currently stuck on the following ...
J. Doe's user avatar
  • 183
2 votes
1 answer
30 views

Print a String Before a Get-ChildItem Value

I'm using the following command to count the number of files by file type in a directory: Get-ChildItem -Path "C:\My\Folder" -Recurse -File -filter *.heic | Measure-Object | %{$_.Count} ...
GTS Joe's user avatar
  • 3,664
0 votes
1 answer
13 views

Powershell: GCI to Find Files Recursively & Copy to Locations Where Filenames Exist

One of my external hard drives recently failed, and I had to employ a somewhat unorthodox procedure to recover my files. I won't bore you with details, but the end result was that after the recovery ...
tnpir4002's user avatar
0 votes
1 answer
42 views

How to run script flush all Azure Redis

I tried to set up the end task after deploying the Web App to clean the cache in Azure Redis to avoid making old caches effective. I tried both command az cli, and Powershell both of them did the same ...
ATY's user avatar
  • 41
2 votes
1 answer
41 views

Enabling specific printer features using PowerShell command

I am seeking assistance regarding a PowerShell command to enable specific features under the "Advance" tab in printer properties. Specifically, I am interested in enabling the "Start ...
Thaju89's user avatar
  • 23
1 vote
2 answers
31 views

Powershell Import Excel Range to 2Dim Array

I have multiple Excel Files where have nearly the same structure: Now I want to collect the Data reorganize it and save it to an single CSV. How can I save the Range (A2:C12) to an 2dim Array? 2. ...
TheRob87's user avatar
-2 votes
0 answers
25 views

Black screen on Windows server after replacing via cmd registry with powershell [closed]

I have a virtual machine with an Exchange server installed on it. I needed to change it so that by default the commands would be executed in powershell and not in cmd. I found this command and applied ...
SanyaKirilloff's user avatar
2 votes
2 answers
83 views

Powershell ForEach-Object processing files in a directory more than once

I have a series of files that all were exported from a base system (Remedy). By default they have 32 characters of ID related information before the filename. I would like to strip these characters ...
LadyTevish's user avatar
-3 votes
0 answers
30 views

Removing duplicates in different files using Powershell [closed]

Lets say I have a several text files: aAll.txt aYellow.txt aBlue.txt aGreen.txt aAll.txt contains 5 names: Alex B. John D. Peter L. Teresa D. George. I. aBlue.txt contains 2 names: Peter L. Teresa ...
noobCoder's user avatar
-2 votes
0 answers
26 views

The issue with removing WSL (Windows Subsystem for Linux) [closed]

I can't remove WSL from my computer. When I try to execute any command with WSL, I get an error like this, which is probably causing Docker to not work. Screenshot of the error. Is there any other way ...
FloriDitch's user avatar
0 votes
1 answer
30 views

Powershell / Multiple Checkboxes, one event handler

I am making a PowerShell script that creates a graphical user interface (GUI) application using Windows Forms, and allows the user to select specific mailbox properties via Check Boxes (e.g., ...
DaffyStackOverFlow's user avatar
0 votes
0 answers
28 views

Could Powershell Out-File be silently failing to write lines to a file?

I have a powershell script that loops through a list of products, and calls a web service to get data for each product, then writes that out to a .csv file. Recently we discovered that there are ...
CodeRedick's user avatar
  • 7,346
1 vote
1 answer
17 views

Invoke-RestMethod - restAPI call fails with an error of 'Invalid flavor'

I am trying to figure out how to post a sample post on the RegEx101, using their restAPI, specifically Create an Entry example. There are not any code examples provided for PowerShell, I tried to ...
Ralf_Reddings's user avatar
1 vote
2 answers
22 views

How to run powershell with a command containing quote?

I want to use the powershell command in this post However, my command contains quote itself, like below: call mybatchfile "%~f1" "%~2" How to invoke it from powershell? Double ...
alancc's user avatar
  • 453
1 vote
0 answers
12 views

How can I run a .exe as an on a remote computer/computers with elevated privileges using a poweshell script? [duplicate]

I need to run a Powershell script that executes a specific .exe file at a specific windows file path. The .exe file needs to be run with certain custom parameters and it needs to be run as an ...
jkev89's user avatar
  • 11

1
2 3 4 5
2295