Questions tagged [powershell-5.1]

280 questions
0
votes
0 answers

System.IO.StreamReader turns into unreadable Deserialized.System.IO.StreamReader when passed to a script block

I'm trying to process the output of a Process using a job because I need it to be parallel but the System.IO.StreamReader turns into a Deserialized.System.IO.StreamReader that doesn't have any way of reading from it and I can't find any…
Knyri
  • 2,968
  • 1
  • 17
  • 24
0
votes
0 answers

How to apply the GPO settings by using PowerShell scripts

We required your help to create the GPO settings via PowerShell script. Example : I would like to apply the GPO settings to Disabled the option turn of the handwriting recognition error reporting via using from PowerShell. I know the steps how to…
0
votes
1 answer

Trouble validating file path in PowerShell script

I am having some trouble validating a file input in a script. Using the following function Function pathtest { [CmdletBinding()] param ( [ValidateScript({ if (-Not ($_ | Test-Path -PathType Leaf) ) { …
StackExchangeGuy
  • 741
  • 16
  • 36
0
votes
0 answers

Getting "Can't find the drive. The drive called 'IIS' does not exist." on first request

Working on Windows Server 2019 Datacenter, $PSVersionTable.PSVersion 5.1.17763.2931 In a powershell script started as admin I have to check if an IIS AppPool exists. I used Get-Item -Path ("IIS:\AppPools\$apppoolname") -ErrorAction SilentlyContinue…
Trix
  • 1
  • 2
0
votes
0 answers

PowerShell Invoke Command, Script not returning some values from remote PC's

I'm new to scripting so please excuse me if my script is messy. This script pretty much does what I want it to do but for 2 fields it doesn't return the values. If I run the commands without Invoke I get all the values I want but when I run this…
0
votes
0 answers

Parsing SQL results for word "Error" using Powershell

What I am looking to accomplish is needing to parse sql results for the word error which will be sent to a logmessage in ELsastic with a -loglevel of "error" when the word error is present. What I have already implemented is LogMessge -messagetolog…
0
votes
0 answers

Impossible to catch exe output in PowerShell

I have been trying to write a script to automate software installation (IBM Spectrum Protect) for several days but I have a problem getting the output of an exe command. This command aims to verify that the client is able to reach and is registered…
Herunòla
  • 13
  • 2
0
votes
1 answer

How can I get the size of a mail (and attachments) in ExchangeOnline using Powershell

The wider context of this is that I am trying to write some powershell code to extract a listing of the contents of my Office 365 mailbox in CSV form including the size of each item to help me to do some subsequent analysis of where the storage in…
0
votes
0 answers

How to setup up Proxy Credentials for Powershell to prevent "Unable to connect to the remote server" Error

I am getting the following error when trying to install Chocolatey through powershell on Windows: Exception calling "DownloadString" with "1" argument(s): "Unable to connect to the remote server" Using the equivalent command for the command line…
LuGa
  • 3
  • 2
0
votes
0 answers

AccessViolationException when calling Marshal.PtrToStructure method within PowerShell

I have implemented and used the code snippet from the post: Add proper p/invoke signature to PowerShell script However, the script only works consistently if run from PowerShell ISE or if embedded as a function in a module and then call it…
Kanuc
  • 25
  • 6
0
votes
1 answer

In a file content - find a line and column from the offset

I have a file called C:\FindPos.txt with this content: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut. I have an Offset and want to find the Line and Column The word incididunt ends on Offset…
Zikato
  • 536
  • 9
  • 18
0
votes
0 answers

Get-ADUser output manipulation

I run the following against my client's AD... It produces what appears to be CSV. $members=Get-ADGroupMember -Identity "my ad group" -Recursive | % {Get-ADUser -Identity $_.distinguishedName -Properties * | ? {$_.enabled -eq $true} | select-object…
Jepper
  • 1,092
  • 3
  • 11
  • 24
0
votes
0 answers

Powershell | Select-String multiple lines regex pattern filters nothing

The situation I have a string like this: some-text some-other-text From which I want to get only what's commented, so like this: What I've tried I read similar…
Bit
  • 21
  • 7
0
votes
0 answers

Why is not "Run this program as an administrator" option checked?

I can add "Run this program as an administrator" option to any shortcut like this with Powershell: $Shortcut = "C:\Users\DR. ÇAĞATAY KAYA\Desktop\chrome - Kısayol.lnk" $Bytes = [System.IO.File]::ReadAllBytes($Shortcut) $Bytes[21] =…
user10825637
0
votes
0 answers

Looping through PSObject from JSON response

I am running Invoke-RestMethod to get a response from an API. That response is in JSON format and I am trying to figure out how to get access to the individual properties in my Powershell code. Given these two lines: $response = Invoke-RestMethod…
dmikester1
  • 1,374
  • 11
  • 55
  • 113