Category "powershell"

Max size of ScriptBlock / InitializationScript for Start-Job in PowerShell

When you start a new job with Start-Job, you can pass it a ScriptBlock and a InitializationScript for example: Function FOO { Write-Host "HEY" } Start-Job -

tsc.ps1 cannot be loaded because running scripts is disabled on this system

On PowerShell, I got the error message when executing tsc. This never happened before. I am not sure should I mingle with the PowerShell security settings to r

PowerShell cmdlet to apply Password to Never Expire policy in M365 tenancy to all users (including current and new users)

I have run the following cmdlet in PowerShell to disable the Password Expiration policy in my M365 tenancy for all users. However, the cmdlet is not applied to

Is there a way to set a variable up to place output to stdout or null?

I would like to set up a variable in my code that would ultimately define if I'll see some output or not. "hello" writes to stdout "hello" > $null supresses

Loading Assemblies from NuGet Packages

Sometimes in my PowerShell scripts, I need access to a specific DLL, using Add-Type -AssemblyName. However, the DLLs I need aren't always on the machine or in t

Getting MSI Summary Information

i want to get the MSI Summary Information with PowerShell i found several scripts and code snippets for opening the "normal" Tables of MSI. So here is my questi

Why powershell does not run Angular commands?

I have started to learn Angular but I note that powershell in Windows gives me an error whenever I make an angular command like: ng new new-app or ng serve

Exporting Public Folder ClientAccessPermissions to csv

So, I thought that it should be easy enough to A) Export a list of all our Public Folders B) Export a list of all our Public Folders with users who have access

ConvertTo-Json on VMWare objects doesn't work

In powershell while converting VM objects to json , ($json = ConvertTo-Json $vm -Compress) i am getting "An item with the same key has already been added" exc

Trying to install Angular 2 Material from npm - unrecognized token in source text

I try the following command from PowerShell (as Administrator) npm install @angular2-material and get the error: Unrecognized token in source text. At line:

PowerShell Script to set the size of pagefile.sys

How to set the size of Page File on Windows(pagefile.sys) via PowerShell?

PowerShell and process exit codes

This self-answered question tries to address two distinct aspects of dealing with process exit codes in PowerShell: In PowerShell code, how can you query the e

Powershell: Two dimension arrays

The following works as expected: $values = @( ("a", "b"), ("c", "d") ) foreach($value in $values) { write-host "Value 0 =" $value[0] write-host "Value 1 ="

How can ensure that a function only accepts a positive integer?

I want to do some basic validation on a user input in PowerShell to ensure a user can only enter a whole integer and does not enter -7 for example. I am not sur

Can Powershell Run Commands in Parallel?

I have a powershell script to do some batch processing on a bunch of images and I'd like to do some parallel processing. Powershell seems to have some backgrou

check if an string exists in a list of strings, using powershell

I have Powershell version 3,4 and 5 in my environment. When I write below code it continously gave me false, though $CompatiableOS contains output of $OSverions

The term 'AzCopy' is not recognized as a name of a cmdlet, function, script file

I need to copy tables from table storage into a different storage account. When attempting to execute AzCopy I'm getting the following exception: The term 'AzC

Powershell - windows hard-disk health status is giving inconsistent results

I am using the below PowerShell script to fetch hard-disk health status of windows machine: Get-PhysicalDisk | Select HealthStatus Issue: For few of the machine

How do I get only directories using Get-ChildItem?

I'm using PowerShell 2.0 and I want to pipe out all the subdirectories of a certain path. The following command outputs all files and directories, but I can't f

PowerShell Cannot dot-source this command because it was defined in a different language mode

I've created a Windows application package using Visual Studio and when I run Add-AppDevPackage.ps1 script I get this error on some computers. Cannot dot-sourc