Function not accessible in a ScriptBlock

PowerShell
I have a script that has some functions and then multiple jobs in the very same script that use those functions. When I start a new job they don't see...
2 years ago

How to get PowerShell error detail from function called from inside a ForEach loop

PowerShell
This code works as expected: function Foo ($Dividend) { $Divisor = 0 $Quotient = $Dividend / $Divisor } try { Foo 1 } catch { $Line ...
2 years ago

Powershell Script for Finding Modified Date of a file/folder

PowerShell
I am very new to Powershell and I was hoping I could get some help creating a script that tells me the modified date of a file. I wish I knew more ab...
2 years ago

Powershell Assigning and Retrieving Variables

PowerShell
So I have been battling all day with Powershell. I'm trying to make something like I put down here. I declare a Variable in the beginning of the scri...
2 years ago

Invoke Sync with Powershell

PowerShell
Normally, I integrate the deployment source to webapp, and then run the 'Sync' button found in the webapp dashboard as and when required to sync the A...
2 years ago

How to format a DateTime in PowerShell?

PowerShell
I can format the Get-Date commandlet no problem like this: $date = Get-Date -format "yyyyMMdd" but once I've got a date in a variable, how do I for...
3 years ago

Powershell CSV to SQL Query

PowerShell
I am back on my on-going learning into powershell, I have hit the limits of my capabilities. So wondering if anyone can throw me in the right directi...
3 years ago

PowerShell equivalent to grep -f

PowerShell
I'm looking for the PowerShell equivalent to grep --file=filename. If you don't know grep, filename is a text file where each line has a regular expre...
3 years ago

Pester PowerShell testing for a sample script is not working as expected

PowerShell
Hi all I have a written a sample script to find whether the given string is Palindrome or not as follows function Palindrome1([string] $param) { [s...
3 years ago

Powershell calling function with argument as string

PowerShell
I am trying to call Get-ChildItem function from custom function. The problem is the arguments to the function can be dynamic. function Test { Get...
3 years ago

delete objects from array when their path property equals object in another array

PowerShell
I have an $array of PSCustomObjects which contain a path,days,filter and recurse property I Test-Path the path of each PSCustomObject and if it's fal...
3 years ago

accountExpires properties not changing format

PowerShell
so i have this one liner that returns specific properties about all users in AD. My issue is that it keeps returning the "accountExpires" field blank...
3 years ago

Account expiry dates or account Never expire for all AD users

PowerShell
While I am running the below command getting expiration_date is blank. Is it possible to get the 'Never expire' instead of blank in expiration_date? ...
3 years ago

PowerShell split not working using words (read from file)

PowerShell
I am trying to extract the sentences that appear between a particular pattern of word, from a file. The intention is to extract the sentences that app...
3 years ago

How to import an external DSC module into PowerShell environment?

PowerShell
I have Windows 10 / Windows 2016 TP5 (PowerShell 5.1). I want to use a PowerShell DSC module from GitHub in my configuration, for example xTimeZone. ...
3 years ago

Matching free() and malloc() calls with regular expressions

PowerShell
I'm creating a powershell script that parses a file containing C code and detects if it contains calls to free(), malloc() or realloc() functions. fi...
3 years ago

PowerShell - Net Use check if exists

Powershell
I'm doing a Power-Shell script to remove connection without using the net use * /delete. Is that any way i can check on the connected Remote first bef...
3 years ago

Get a count of users in a specific OU and its sub OU's

Powershell
I'm looking for a powershell script that will get me: The name of the OU's The count of the number of AD users in each OU. I have found this: (...
3 years ago

Here-String prints extra lines when piped to Out-File

Powershell
I'm trying to programattically create a file using Powershell (I know, noob stuff) with multiple lines of content. My attempt is as follows: $Servic...
3 years ago

How can I verify if an AD account is locked?

PowerShell
I want to know if it is possible to verify if a specific AD account is locked. The command Get-ADUser does not return this parameter : -----------...
3 years ago