Questions tagged [powershell-5.0]
For questions specific to Powershell Version 5
87
questions
0
votes
1
answer
20
views
Search a file on all volumes in the computer
I'm trying to search for a file on all volumes on my computer
I was not successful with the answer from this link:
get-childitem-with-multiple-paths-via-variable
I tried:
$Location = 'c:\*', 'd:\*', '...
1
vote
1
answer
18
views
Command to delete blank lines in txt file doesn't work with variable in file path
Command to delete blank lines in List.txt file, doesn't work when I use variable $env:username.
Works: Using CMG username in file path.
$linblk = [System.IO.File]::ReadAllText('C:\Users\CMG\Desktop\...
1
vote
1
answer
49
views
Generate txt report of files copied between two folders
I have a script that copies audio files from one folder to another.
Script:
$tot = 0
$files = 'C:\Users\CMG\Desktop\List.txt'
$location = 'C:\Users\CMG\Desktop\Select Dance\'
$destination = 'C:\Users\...
1
vote
1
answer
28
views
Change brackets to parentheses in filename
I need to recursively change the square brackets in the names of audio files to parentheses within multiple folders.
Original name:
Gonna Get Along Without You Now [Strelka Sounds Edit].mp3
I tried:
...
1
vote
1
answer
145
views
Copy audio files from multiple subfolders to another folder using List.txt file
My Powershell version is 5.1.19041.1645
I want to copy audio files from several folders to another folder using the txt files where the song names in the List.txt file have a different structure than ...
0
votes
0
answers
43
views
Find what port number is in use by a service
So I'm trying to take a windows service on one of our servers, "SC - ATM-Encryption" and find out what port it is using. All answers I've seen close to what I'm asking have me doing:
netstat ...
0
votes
1
answer
31
views
Power shell script for Monitoring C-Drive
# find the path to the desktop folder:
$desktop = [Environment]::GetFolderPath('Desktop')
#specify the path to the folder you want to monitor:
$Path = $desktop
# specify which files you want to ...
0
votes
0
answers
113
views
How to set the local user account photo with PowerShell?
I want to set the local account photo (the image that shows up in the start menu and above the password prompt when logging in) using PowerShell and an image saved in a certain location.
the same as ...
0
votes
0
answers
101
views
uninstalling the chrome using powershell script
I am trying to uninstall google chrome using powershell script but it shows me a popup to choose uninstall/cancel. How can i supress this by choosing uninstall button?
Set-Location 'path\to\my\chrome' ...
0
votes
1
answer
2k
views
Get-AdGroupMember for multiple groups
How do I check if the mentioned security groups exists or not? I would also want the exported .csv to mention 'No members' instead of skipping it.
Also, how do I refine below script? And I would like ...
0
votes
0
answers
26
views
Stop Powershell from making new line for each argument using pscp
I'm trying to copy a log file from a Linuxserver using this Powershellscript.
$serveruser = 'user'
$passwd = 'somepw123'
$saphost = 'SAP1'
pscp -pw $passwd $serveruser@$saphost':/var/log/...
0
votes
1
answer
18
views
What is the hierarchy of login activities user startup scripts, group policies, etc. - Windows 10
Trying to understand what is the hierarchy of login/startup scripts that trigger when a user logs in to Windows 10 and if this is impacting a local user command script in the startup from taking ...
0
votes
0
answers
40
views
How to compare two Excel .xlsx files in PowerShell and output differences in another file
I have used the below code to compare the two files excel1 and excel2 and write the difference out to another file, but the output format is way different than expected.
Clear-Host
$File1 = Get-...
2
votes
0
answers
213
views
Get user profile size?
Wait... before you guys come at me about this being asked before, I assure you it's a bit different. I know how to recurse through directories and measure the sum of each container, to include ...
0
votes
1
answer
82
views
PowerShell Programming: Traverse folders and subfolders and apply pdftotext. I/O Error
I have correctly written the following PowerShell command to traverse every folder and subfolder of a directory and display the contents of each such folders:
Get-ChildItem -Path "C:\whiskey\...
2
votes
0
answers
186
views
Why does calculating folder sizes with Robocopy.exe give me different results compared to Get-ChildItem?
I have this Function that takes a path input, and gives you the size of it. There are 3 different options you can choose from which are:
'GCI' - Get-ChildItem
'DIR' - CMD's DIR command
'ROBO' - ...
1
vote
1
answer
121
views
Windows 10 PowerShell 5.1 new-filecatalog unable to find files
I'm trying to create a catalog to verify a backup created by RoboCopy, containing ~150GB / 100K files, using New-FileCatalog in Windows 10 via:
New-FileCatalog -Path I:\Users\ -CatalogFilePath .\...
0
votes
0
answers
122
views
Why vagrant claim about Powershell version (minimum 3)?
Trying to use Vagrant and it claims about Powershell minimum version 3 installed.
I have Windows 10 Pro and Vagrant 2.2.16 and the minimum version at Windows 10 is 5.
Tried to use chocolatey and ...
0
votes
0
answers
27
views
RunAs command to apply restrictions to a local account created during the OOBE process of AutoPilot in INtune
I am trying to use a RunAs command that will be wrapped in an Intunewinapp to apply restrictions to a local account. Currently, I am able to create the account during the OOBE process of AutoPilot, ...
1
vote
1
answer
55
views
Regex: Put some tags at the beginning of the line, but only those that are framed in a comment html
I wanna put some tags at the beginning of the line, but only those that are framed in a comment html. For example:
<!-- ARTICOL START -->
<p class="text_obisnuit">I want go home&...
0
votes
0
answers
68
views
Is there a way to get the progress of a Remove-CimInstance while the actual deletion is in progress?
I currently have a script that will delete a profile, or multiple off a local or remote PC. What I use at the moment to do so is Remove-CimInstance against the win32_userprofile class for a specific ...
0
votes
1
answer
153
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
1
answer
92
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
1
answer
139
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
1
answer
47
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
0
answers
150
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
0
answers
320
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
1
answer
109
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
0
answers
112
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
2
answers
72
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
1
answer
940
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
1
answer
177
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
1
answer
78
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 ...
1
vote
1
answer
967
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
0
answers
45
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
1
answer
315
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
1
answer
182
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
1
answer
199
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
2
answers
2k
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
1
answer
145
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
0
answers
457
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
1
answer
1k
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
1
answer
219
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
1
answer
11k
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
1
answer
34
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
1
answer
1k
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
1
answer
5k
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
1
answer
2k
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
1
answer
243
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
1
answer
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 ...