Access XML attribute with powershell fails for one node but not another

PowerShell
So I have this function that I'm using to get the attribute 'type' from one of my XML nodes. There are at least two of these Nodes in the XML file. T...
2 years ago

Midnight last Monday in Powershell

PowerShell
I'm trying to hack up a script that returns the amount of email received to and sent from certain mailboxes today, this week and this month. I wrote ...
2 years ago

Login-AzureRmAccount command not working from hosted c# application

PowerShell
I am using powershell script to login into azure and for that i write simple command "Login-AzureRmAccount" and call that script into c# code on butto...
2 years ago

Sorting using the sort object in PowerShell part 3

PowerShell
Changed my code a little from part 2 example below but taking part 2 example which works great thanks to a member in stackoverflow. [string] $Source...
2 years ago

How to get process id by its service name with a script to variable

PowerShell
I have service named WinDefend and it runs on process svchost.exe There other many svchost.exe processes and I need to find a way to get its ID. when ...
2 years ago

Regex to capture CVEs from Nessus plugin output

PowerShell
I have a block of output that looks like this: - KB3167679 (MS16-101) (2 vulnerabilities)The following CVEs would be covered: CVE-2016-3300, CVE-201...
2 years ago

How to count the result of a if loop within foreach loop

PowerShell
Is there a better way to be able to count the amounts of empty groups than using this method and then calling $count + 1 for each result? I tried to m...
2 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...
2 years ago

How to open Powershell Console Window from Powershell

PowerShell
I am writing a script to use multiple plink (PuTTY) sessions as a Windows version of clusterssh. I am stuck however because I want to open multiple P...
2 years ago

Powershell search till a particular keyword

PowerShell
I'm trying to search and extract the sentences that start with a particular keyword, and which exist between/starts/ends with a keyword. The intention...
2 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 ...
2 years ago

PowerShell Remove item [0] from an array

PowerShell
I'm struggling a bit to remove the first line (item ID) of an array. $test.GetType() IsPublic IsSerial Name Base...
2 years ago

Get-Eventlog group by Event and Day

PowerShell
Get-EventLog -Logname system -Source "Microsoft-Windows-GroupPolicy" -EntryType "Information"| group-object -property source | sort-object -property T...
2 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...
2 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...
2 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...
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...
2 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...
2 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...
2 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...
2 years ago