Questions tagged [powershell-5.0]

For questions specific to Powershell Version 5

Filter by
Sorted by
Tagged with
0
votes
0answers
28 views

Command to make powershell console window hidden not working

I have a script that needs to run as administrator and hidden on my computer. I am able to initially call it as a hidden process but if the script fails or the code changes I will call it again: ...
0
votes
0answers
60 views

Notice When Window Being Created of Other Thread or Process using Powershell

Is there a way to get a notice when there is a window which has just been load and going to be created (e.g. after clicking a button) within other thread or process? I want to use it in Automation for ...
1
vote
1answer
415 views

Powershell Monitor Clipboard Change

I'm trying monitor clipboard change by powershell, and not consider to use comparing (Get-Clipboard) before and after change because it cannot distinguish between "two copy are identical" and "haven't ...
0
votes
0answers
26 views

'Foreach Recipient in Recipients' not work correctly in Powershell

The recipients of a mail in Outlook 2010 are as follow. I tried to use foreach to delete all of the existing recipients but it failed to delete all(but deleted some). Also the dummy Write-Host (the ...
0
votes
1answer
176 views

Remove directories / sub-directories when path could be any of 50 using PowerShell 5 or >

Windows 10 64-bit. PowerShell 5.1 Remove directories / sub-directories when path could be any of 50 using PowerShell 5 or >. Remove livebolivar.com and it's sub-directories from any of 50 folders ...
8
votes
1answer
137 views

What does ${$} mean / do in PowerShell?

While learning PowerShell, I executed the command ${$} by mistake and got an output like this: PS C:\Users\myuser> Get-ChildItem Env: | Out-File -FilePath $home\env.txt PS C:\Users\myuser> ${$} ...
0
votes
1answer
55 views

How do I alias this in PowerShell

I would like to alias the rather wordy command, Remove-WebApplication -Name portal -Site "Default Site", but when I try: Set-Alias RemPortal Remove-WebApplication -Name portal -Site "Default Site" ...
0
votes
0answers
17 views

AWS VPNConnection using Powershell

I am trying to setup a new vpn connection with the AWS transit gateway using PowerShell. I need some assistance on how to setup tunnel options. AWS has very limited documentation with examples. Here ...
0
votes
1answer
245 views

How to capture / record / download multiple streaming audio urls with a cmd or PowerShell script?

Windows 10 64-bit. How to capture / record / download multiple streaming audio urls with a cmd or PowerShell script? I capture 15 .mp3 audio streams from 15 servers for an hour every night using a ...
0
votes
0answers
52 views

Batch load Powershell script bypassing execution policy, with Powershell script that then self-elevating

The below code does bypass the execution policy for this one script, and prompt a Powershell process to elevate, but that elevated window disappears within seconds showing no output. read-host put ...
3
votes
1answer
131 views

Windows 10 regex. Every occurrence of ci not in the words: associate capacitor cellspacing

Windows 10 64-bit. Powershell 5. Notepad++ v.7 32-bit Regex: Every occurrence of ci not in the words: associate associates associations capacitor cellspacing cig cipher circle circuit circular ...
0
votes
0answers
84 views

Unicode in powershell scripts

In my profile.ps1 I have this write-host "→" in the console it appears as → Though if I cut-n-paste the line into the console it looks like > Write-Host → > → So there's obviously no ...
0
votes
0answers
25 views

sql in Powershell for windows 7

I need to run a fairly basic SQL query from Powershell on an older 32 bit win7 PC, I'm having issues running as the invoke-sql cmdlet is looking for the microsoft.sqlserver.batchparser assembly. I ...
1
vote
1answer
131 views

How to try/catch an export-csv file

The code I am using is below. The code works fine and does what I want it to do except for the try/catch portion. I'm using SCCM 2016, Windows 10 Enterprise 1709 and PowerShell v5. The main problem is ...
0
votes
0answers
45 views

How to get PowerShell console UI look from Win10home on Server 2k12R2

Here is what I mean, and I dont see this in properties: In Windows 10 Home or Professional, the newer Powershell builds have a nice format for different things such as variables being green, cmdlets ...
0
votes
1answer
94 views

sqlcmd hangs when started on powershell Ise

I had sqlcmd - Microsoft command line utility - working on Powershell Ise. After installation of SSMS 17 and newer odbc driver, it stopped working. When I start it, it just hangs. It does works on ...
0
votes
1answer
3k views

PowerShell Set permissions on a folder/directory from the command line

Is there a better / easier way to set permissions on a Windows folder from the command line? I am using powershell, get-acl and set-acl. # Set permissions on a folder using powershell, get-acl and ...
-1
votes
1answer
30 views

How to add SAMAccount to results?

Stuck on how to add SAMAccounts (AD usernames) to the results, can anyone help? Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | where {$_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_....
0
votes
1answer
387 views

pdfinfo.exe isn't working on Powershell

I am trying to do the PowerShell script outlined in the answer here. The question and solution reference "pdfinfo.exe" and "pdfinfo". When I research this, it looks like it should be packaged in ...
0
votes
0answers
2k views

Powershell, Posh-SSH Module: How is reading the stream supposed to work in Posh-SSH?

I'm trying to understand how reading a stream is supposed to work in Posh-SSH so I can put together a "wait-action" function so the script will continue only after the remote command has completed. ...
0
votes
0answers
68 views

access hkey_local_machine registry values from windows service running as localsystem

I'm trying to get the full version/build number of microsoft office from a powershell script that runs from a windows service as localsystem. The value I'm looking for is in HKEY_LOCAL_MACHINE\...
1
vote
0answers
348 views

Import and merge 2 CSV files using cmdlets in PowerShell [closed]

I am trying to import and merge columns from 2 CSV file into one using Powershell. Please look at my code and advise. I think that it is right, but I am not sure about referencing different columns ...
0
votes
1answer
954 views

Convert Batch to PowerShell Calling Python Scripts

I have a Batch script that calls Python then runs a Python program. Instead of using a Batch script to do that, I would like to use PowerShell. I am not a programmer nor scripter and I have Googled ...
0
votes
1answer
151 views

Editing an RDP session with Notepad and Powershell

This worked for me: ls "~\desktop\CMR Desktop.rdp" -recurse | %{ (gc $_ ) -replace "session bpp:i:32", "session bpp:i:24" | set-content $_.FullName -force } Instead of the -replace switch, which one ...
2
votes
1answer
1k views

Powershell can't see all files in a directory

Im at a loss with this one. I have a script in the Powershell Directory that I cannot see with Powershell. I've navigated to the directory and ran Dir -Force which should show me all files in the ...
1
vote
1answer
180 views

copy-item working for subdirectories only second time script is run

I have a script that I am using to backup files. For some reason, it is only copying the files and dir of the sub-folder the second time the script runs. The error message is "Container cannot ...
4
votes
4answers
2k views

PowerShell 64-bit hanging on new machine

I recently got a new computer with plenty of horsepower and its works very fast everywhere except PowerShell. Environment: Dell XPS 8930 (i7-8700K, 32GB RAM, 1TB NVMe SSD) Windows 10 Pro with latest ...
1
vote
1answer
88 views

'Get-WindowsFeature -Name Hyper-V' stucked on 20%

I have executed below command : Get-WindowsFeature -Name Hyper-V | Select-Object InstallState It got stucked on 20% I waited for 30 mins but still no response. Any specific reason and how I ...
2
votes
1answer
546 views

Retrieve data from XML file and edit it

Suppose following example: I have an XML file called plants.xml <?xml version="1.0" encoding="utf-8"?> <Plant> <Zone Left="{PRKNG-7}"> <Data key="Bloodroot">...
1
vote
1answer
1k views

PowerShell is missing Import-Certificate

I was trying to install some certificates via PowerShell's Import-Certificate command, which works great on Windows 10. When I ran it on Windows 7, Import-Certificate wasn't found. I downloaded WMF ...
1
vote
2answers
730 views

Why does this Powershell Script create converted images OUTSIDE the Rootfolder?

The following Powershell script is supposed to process all designated images INSIDE the specified Rootfolder. Some of the renamed output images are generated OUTSIDE the Rootfolder. Any Powershell ...
5
votes
1answer
3k views

Programmatically create machine startup script in local Group Policy: script executes but is not visible in Group Policy Editor

I have managed to programmatically create machine startup Powershell script for Windows 10 Pro and place it in the local Group Policy (see below a powershell script used for creation of startup script)...
0
votes
0answers
200 views

Powershell ISE: Closing a PowerShell Tab does not unlock a dynamically loaded .NET assembly

Please consider the following scenario. Launch Windows Powershell ISE (64 bit) Create a new PowerShell Tab Create a new PS script which loads a custom assembly by invoking [System.Reflection....
5
votes
1answer
14k views

Setting window size and position in PowerShell 5 and 6

Problem: We have a large television we use for presentations, that isn't exactly 1920×1080 px. It's off and I can't control it. What I can control is my windows laptop that I connect to it. I have ...
1
vote
1answer
284 views

Bug in PowerShell classes when script is in a folder containing a single-quote?

My client's PowerShell scripts aren't working for a new user who happens to have a single-quote in their name - which means their profile path is called "C:\Users\Liam'OReilly". It appears to be a bug ...
3
votes
1answer
1k views

Powershell 6 missing cmdlets

Why are cmdlets like Test-NetConnection no longer available? It appears the entire NetTCPIP module is not in v6. Is there a list of depreciated cmdlets in Powershell Core? Get-Module -n Microsoft....
1
vote
1answer
1k views

Install multiple .cer (certificates) from a network directory using powershell, but first check if they are already installed

I am still learning the ways of powershell, and am having difficulties solving a problem. I would like to have the following logic flow: Go out to \fileserver\certs and pull all thumbprints for each ...
3
votes
1answer
2k views

Configure Windows Update in Windows Server 2016

Problem Enable Windows Update to Automatically download and schedule install. Schedule to run on a particular day (Saturday). Solution I tried Write a powershell script using gpmc/grouppolicy ...
0
votes
1answer
112 views

My script overwrites the previous entry after each “foreach” loop

The script I have here writes out the information I want. However I've noticed that each new valid entry replaces the last. I cannot figure out why. So what I end up with is just 1 entry every time ...
1
vote
2answers
1k views

Out-File does not show all my columns

Get-ADComputer -SearchBase "DC=some,DC=website,DC=net" -Filter * -Properties Name,Created,whenChanged,LastLogonDate,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,...
4
votes
5answers
28k views

Update Powershell through command line

I want to update a machine's Powershell version. Can this be done through the command line? My present need is to update from PS 4 to PS 5 on a Windows server 2012R2. I guess there is no catch-all ...
0
votes
0answers
515 views

Error when cleaning Windows recycle-bin with Clear-RecycleBin

I use this to clear the recycle bin of Windows: powershell -command "& {Clear-RecycleBin -force}" or even simpler powershell Clear-RecycleBin -force The command appears to work, but there's an ...
2
votes
1answer
11k views

How can I list all members from AD group showing enable and disabled users?

I'm trying get a list of all members from a AD Group showing active \ inactive users. The purpose is get all the members on the groups and list the ones with Admin privileges. I did the following ...
18
votes
1answer
8k views

How to colorize the Powershell prompt?

I always make my prompt to be this color in my linux Then I can find my input in the black command window. But can we make the same color in my Powershell?
2
votes
1answer
704 views

Unable to Copy Files in PowerShell using PSSession and Copy-Item cmdlet without a Method Invocation Error

I have a PowerShell script that attempts to transfer files from an old machine to a new one. This is occuring on Windows 10 with PowerShell v5. For this purpose I'd prefer to use PSSession to transfer ...
3
votes
3answers
2k views

PowerShell issue - IF statement curly brackets

I’ve come across something with PS and I don’t know if I’m doing something wrong or maybe it is just a bug in PS (and I can’t find the answer anywhere)? I’ve tested this with PS v4, v5.0 and v5.1 ...
0
votes
1answer
775 views

Unhandled Powershell error on launch

I randomly started getting an unhandled exception when trying to launch powershell x64 this evening. It was working just fine before I put my computer to sleep a few hours ago. Unhandled Exception: ...
1
vote
2answers
370 views

Where-Object not returning any contents

I'm getting started with Windows server 2016, and I'm using a CLI only version. I'm trying to determine what features are installed on my Computer. I tried to do so by viewing stuff with Get-...
1
vote
2answers
707 views

Showing all glyphs in PowerShell

My version is 5.1 but the Lucida Console font is not able to show the full range of glyphs for most, if not all, Unicode characters. Isn't PowerShell making use of the installed fonts in the Windows ...
1
vote
1answer
561 views

Get HostName for Each RemoteAddress IP in New Member

I have a PowerShell script, which has some variables $GetCon : Get Tcp Connection in Powershell $hn : Get expand Remote-Address in $GetCon. $rrt : is a Number of all results, it's all connection IP's....