Questions tagged [powershell-5.0]

For questions specific to Powershell Version 5

Filter by
Sorted by
Tagged with
0
votes
1answer
30 views

New-Item returns WriteError: FileNotFound Exception

Still pretty new to powershell so maybe this is an easy fix. I am running powershell as administrator so I should be able to do what I want-however I can't for the life of me figure out this issue. It ...
2
votes
1answer
33 views

Echo statement is not working inside ForEach-Object loop unless you use break statement. Why and any alternative to fix this?

I was designing my own function which renames the .ps1 file to .psm1 with the same name of .ps1 file. Example: Add-UdfUser.ps1 will become Add-UdfUser.psm1. It works completely fine. It changes the ...
0
votes
1answer
30 views

Export-Alias : Access to the path 'C:\Users\Administrator' is denied. Why?

Hey there super user community. I am new to Powershell so I was practicing commands on ISE and I got a error message for the command - PS C:\Users\Administrator> Write-Host | Export-Alias -Name * ...
-1
votes
1answer
40 views

Proper way to migrate a user profile?

I've taken a look at a couple solutions here and other sites in regards to migrating a profile,but they just don't seem to apply in my situation. I have this current script that deletes user profiles ...
1
vote
0answers
16 views

Permanently change Powershell syntax highlight colors lowered execution policy

I changed the colors of Powershell but now the syntax highlights are hard to see so I figured out how to change them but they do not stay permanently. I tried putting the following command in the $...
0
votes
0answers
62 views

PowerShell Increases Disk Size as Desired but Throwing Errors Without any Problems

This script loads a .csv file and iterates through a list of VM's and checks free disk space and if below a certain amount in GB, increases disk space to that specified in the script. If the free ...
0
votes
1answer
60 views

From Powershell, Open Multiple SQL files in a single SSMS Instance

I have an automated Powershell process that ends with an Invoke-Item command to open multiple SQL files (currently 4 SQL files) for the testers, so they can run their scripts. Keep in mind, I am not ...
2
votes
0answers
57 views

Windows Explorer View Option via PowerShell

We would like to apply some Explorer folder settings to our user profiles where the following options are set View: Details Columns: Name, Date Mondified, Type, Size, Path Sort By: Date Modified ...
1
vote
2answers
36 views

gvim 8.2 doesn't redraw the screen when editing a git commit message in windows 10 powershell

I installed vim on windows 10 using chocolatey. When I edit a file in powershell, everything works great! I even got copy and paste to work. However, when I edit a git commit message, vim doesn't ...
0
votes
1answer
217 views

Configure gvim swap, undo, and backup files on windows

I installed vim on windows 10 using chocolatey. When I edit a foo file in powershell, vim leaves behind .foo.un~ or .foo~ files. What are these and how do I stop vim from leaving them around?
1
vote
1answer
43 views

gvim 8.2 doesn't paste on windows 10 in powershell

I installed vim on Windows 10 with chocolatey. Copy and Paste don't work when I invoke vim in powershell. I expect them to work as long as I'm in insert mode. How can I make copy and paste work?
3
votes
1answer
65 views

How to get list of CLSIDs along with their associated COM Object names?

Searching for the ways to generate or get the list of CLSIDs, I found this link, that actually does it. But it's rather incomplete in my opinion, the complete list would include CLSIDs with their ...
0
votes
0answers
135 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
62 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
655 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
36 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
244 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
163 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
86 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
2answers
1k 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 ...
3
votes
1answer
141 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 ...
1
vote
0answers
337 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 ...
1
vote
1answer
633 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
1answer
166 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
9k 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
960 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
1answer
3k 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
1answer
1k 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
191 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
3k 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
305 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
4k 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
184 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
675 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
2k 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
798 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
2answers
4k 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
258 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....
6
votes
1answer
21k 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
376 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
3k 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
175 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
2k 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,...
21
votes
6answers
54k 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
1answer
728 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 ...
3
votes
2answers
20k 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 ...
22
votes
1answer
11k 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?