Replace a character with new line

PowerShell
Powershell ver 4. Windows 7 I wanted to replace , with new lines in a text file. I tried below script (Get-Content C:\Test\test.txt).Replace(',','`n...
3 years ago

Restricting Powershell Commands by Version

PowerShell
I'm writing a Powershell script (on a Win10 machine) that needs to be backward-compatible all the way to Win7 machines - which shipped with Powershell...
2 years ago

Can I make powershell tab complete show me all options, rather than picking a specific one?

PowerShell
In Powershell, if I type: install-<tab> Powershell tab completion will complete with a single command that starts with install- Install-Pack...
2 years ago

Import-CSV add data Export

PowerShell
I'm having a heck of a time trying to import a CSV and run a Invoke-WebRequest to get data to add to a new Column.. $username = "Username" $password...
2 years ago

PowerShell exit() kills shell and ISE

PowerShell
So I've written a series of functions and inserted them into a PS Module (.psm1). One of which is a simple ErrorAndExit function that writes a message...
3 years ago

PowerShell script to return versions of .NET Framework on a machine?

PowerShell
What would a PowerShell script be to return versions of the .NET Framework on a machine? My first guess is something involving WMI. Is there somethin...
3 years ago

Powershell Create a New Windows 10 VM

PowerShell
When creating a new style VM in azure via powershell i always use this to specify the image Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherNa...
3 years ago

Get a list of users who are not part of ANY group in the active directory

PowerShell
On the internet as well as SO, I can see solutions for finding out all the users in AD or users who are not part of some particular group/groups. But ...
3 years ago

Remove XML Node

PowerShell
I have an XML file which contains a <Notes> node that I wish to remove. <APPOrganisationUnits> <APPOrganisationUnitsRow num="1"> ...
3 years ago

DrawString with outline in image

PowerShell
How I can draw outlined string? For example: solid color of string white, border is black. Which method I must use to get this effect? Maybe somebody ...
3 years ago

While loop continuously looping comparing times

PowerShell
$time = Get-Date -DisplayHint Time $addTime = Read-Host -Prompt "How many minutes until computer turns off?" $addTimeConvert = [timespan]::FromMinute...
3 years ago

Powershell Math CSV

PowerShell
Very little out there about this subject so over to the experts. Say I import a csv into powershell with three columns A, B and Result I wish to di...
3 years ago

Count specific strings with wildcard

PowerShell
How can I count specific strings in a text file with PowerShell? (I know how I can count normal specific strings) My plan is to count domain accounts...
3 years ago

Selected mailbox information missing in exported CSV file

PowerShell
I have been trying to export some mailbox statistics to Excel with Export-Csv. This is the script I came up with, but now I'm at a dead end: Get-Mail...
3 years ago

Usage of | in PowerShell regex

PowerShell
I'm trying to split some text using PowerShell, and I'm doing a little experimenting with regex, and I would like to know exactly what the "|" charact...
3 years ago

powershell if -OR statement with comparison operators not working as expected

PowerShell
I have the following code snippet and I cannot figure out why the if is not working. The goal is to get some input from the user, and if it is a val...
3 years ago

Window Size in Powershell

PowerShell
I'm trying to set size of powershell window using a powershell script. The code I'm using is $pshost = Get-Host $psWindow = $pshost.UI.RawUI $newSi...
3 years ago

Prevent shortcuts pinned to the taskbar by a script from being removed when re-running the script

PowerShell
I have a script that pins application shortcuts to the Windows Taskbar. The script I have works fine when pinning the shortcuts. However, if the scri...
3 years ago

Changing one field in a CSV file fails using pipes

PowerShell
I need to modify one (1) field in a CSV file. I can do it with separate commands, but the CSV file may be large (GiB+). My understanding is that Impor...
3 years ago

Azure Cloud Service Startup Task that requires reboot

PowerShell
Tried with osFamily 4, osVersion * Background: we have an app that uses System.Management.Automation.dll (from the GAC, dev box is W10) to work with ...
3 years ago