Category "powershell"

Why should I avoid using the increase assignment operator (+=) to create a collection

The increase assignment operator (+=) is often used in [PowerShell] questions and answers at the StackOverflow site to construct a collection objects, e.g.: $C

find User in a list of servers PowerShell

I have a list of servers where I have to find a specific user 'adtuser', and if it is part of the admin group in each server, and output a text file. For the mo

How do I amend this PS script to move files into the correct folders?

My current PS script is: $loc = "C:\Users\USER\Desktop\New folder1" $files = Get-ChildItem -Path $loc for ($i=0; $i -lt $files.Count; $i++) { $outfile = $file

Combine PowerShell Defender outlets into a combined CSV file for monitoring

We cancelled our antivirus software (Kaspersky Anti-Virus, duh) and depend on the Windows Defender in the meantime. We won’t be getting any SIEM server to

Filter out all occurrences of given properties from json object

I'm using PowerShell to extract data from an API call, update it and then pass it back to the API. What I would like to know is whether or not there is a simple

Powershell script to create folder for groups with extensionAttribute1 set

Hi I want to write a powershell scrip that creates a folder for groups in a specific OU where I have set the extensionAttribute1. Get-ADGroup -filter * -Search

How to update all Azure Powershell Az modules?

The Azure Powershell Az module comes with an assortment of modules such as Az.Accounts, Az.Aks, etc. Is it possible to update all these Az.* modules at once?

Create unique variables in a loop powershell/Jenkins

I am trying save urls created from an array into unique variables created in a loop in a Jenkins freestyle project. I need to use these variables in the next st

Question about Variables in powershell script

I'm writing a script and I was wondering if there is a way to give a variable for example $a from a script firstscript.ps1 to an other script secondscript.ps1 e

pwsh -Command is removing quotation marks

In pwsh call the following: Write-Host '{"drop_attr": "name"}' Result ok: {"drop_attr": "name"} Now do the same via pwsh: pwsh -Command Write-Host '{"dr

Sitecore Powershell - How to get one or multiple Multlist Value

I have a little bit of confusion regarding the Multilist Field in Sitecore. Basically, I want to get all of the selected MultiList Field in PowerShell to do stu

Powershell Azure Function Fails

First and foremost I'm new to Azure Functions and have only been working with it for a couple of weeks, so please bear with me. I was tasked with taking one of

Try Catch/Exception for ManagementObjectNotFoundException and ActiveDirectory/Outlook

This might be a pretty basic question, but i haven't seen it on the forms. Bear with me i'm new to powershell I'm trying to catch this exception(ManagementObje

How can I use the "PowerShell Integrated Console" in VS Code?

I have the PowerShell extension installed under VSCode. When I open up a PowerShell script, VS Code automatically pops open a "PowerShell Integrated Console" wi

Powershell Read-Host Not adding or multiplying correctly?

What exactly am I doing wrong here, it seems to be subtracting just fine but adding and multiplying seems to not work at all. How do I get it to do the calcula

Error "Cannot bind argument to parameter 'Name' because it is null" when running PowerShell script from C#

AFAIK, the only way to change the type of an Office 365 mailbox to Shared is via Exchange Online Powershell, and seeing that I have to do so from an ASP.NET Cor

npm - The system cannot find the path specified (But then shows the result)

I am using npm after installing nodejs. I have installed it once before and I just finished deleting all the components because it kept giving the error in the

How to find, stop and disable a Windows service using Powershell

I am trying to find a service, stop it and then disable it remotely using Powershell. It can find and stop but cannot disable. For disabling, I have to run the

Return variable from one function to another in powershell

I am inside function #1 and triggering function #2. Function #2 has a variable that I want to get back into function #1 and use it. My output ends up being:

Powershell decimal to [Int] not failing

I am trying to validate a string of what should be comma separated integer values to use as success codes. If I start with an array with some invalid values, li