Questions tagged [powershell-5.0]
For questions specific to Powershell Version 5
120
questions
1
vote
1
answer
63
views
PowerShell 5.1 console: How do I get better default error handling?
In powershell 5.1, the default error response looks like this:
Aug01 14:26:01 C:\> throw [Collections.Generic.KeyNotFoundException]::new('example')
example
At line:1 char:1
+ throw [Collections....
0
votes
0
answers
43
views
Opt in Microsoft Automatic Updates using PowerShell
I am setting up a VM running Windows Server 2022. I'm trying to subscribe to Automatic Updates according to this document I found on MS website.
https://learn.microsoft.com/en-us/windows/win32/wua_sdk/...
0
votes
1
answer
38
views
Output-Grid via PowerShell for all Inbound Windows Defender Firewall Rules
I have a PowerShell script, that works but what I'm having problems with is getting an output grid like an excel sheet.
Here is the code:
Get-NetFirewallRule |
Where-Object {($_.Profiles -band [...
0
votes
0
answers
21
views
How to make the Word-open dialog visible and frontmost?
When Word has following limitation with PDF
when not set as default App for PDF
does not show PDF it exported
cannot Open PDF navigated by Recent Items
I am using PowerShell Script to have Word open ...
0
votes
4
answers
70
views
power shell command not returning System model
I have the following power shell cmd and I would like to get it to return the model # of the PC it is run on.
I am not a programmer, I am simply trying to earn enough power shell to make my work life ...
1
vote
1
answer
595
views
How to add lines above and below a certain line in Powershell based on regex pattern?
03,201779,,01354,73923309,,,TEST2,7962753,,,0343,5087632,,/#end of line
04,399,777873,,,,text234,,,,/
33,TEST1,,,0343,,93493,,,343,,,,TEST3,,,,,,/
37,TEST37,text
49,24605597,6,343,343,343,,,3434,,,/
...
3
votes
1
answer
120
views
Are Classes defined through P/Invoke not allowed to be executed remotely?
To get it out the way: I understand there are different ways to go about this such as Get-ChildItem.
So, I have a custom class I'm defining to get rid of some of the overhead PowerShell cmdlets have, ...
0
votes
1
answer
408
views
How to stop cookie prompt while using Invoke-WebRequest in PowerShell
I have a script that uses Invoke-WebRequest. It has worked fine until yesterday when it pauses for a prompt to accept cookies in a window button.
$webpage = Invoke-WebRequest -SessionVariable session ...
4
votes
1
answer
247
views
Don't want to display WARNING: ACTIONS REQUIRED: while running powershell script
I have written bitlocker code to backup key after old key has been shared with user.
My requirement is that don't want to display WARNING: ACTIONS REQUIRED: while running script
$BLV = Get-...
0
votes
0
answers
49
views
Powershell script block logging - Restrict number of logs
For added safety (STIG Rule ID SV-220860r569187_rule) i activated Powershell script block logging via GPO.
This creates a lot of logs. Cause diskspace is limited (its an industrial PC) i like to ...
0
votes
0
answers
51
views
Scan DHCP logs on all DHCP servers in domain for a specific IP
I need to find out what was a computer name using a specific IP in a specific time. But there are dozens of DHCP servers in the domain and I don't know which server has the relevant subnet in scope. ...
1
vote
1
answer
283
views
validate particular column and its value using powershell
Validate Status Column using powershell. If any status column contain Not-compliant then overall status column needs to be displayed not-compliant. Attached data for your reference.
Trying below code ...
1
vote
1
answer
105
views
Export data to excel by creating instance of the Excel.Application object in PowerShell
Currently i'm using ImportExcel module to fetch data from multiple csv file and export in single excel file. But due to network restriction from this month I am not able to install importexcel module. ...
1
vote
1
answer
521
views
Copy files and only the parent folder the file resides
Copying files but not all the folders, just the one parent/relative folder in which contains the files.
Folder and Files structure:
ExcelData (Folder)
a. File1.xlsx
b. File2.xlsx
c. File3.xlsx
d. ...
1
vote
1
answer
374
views
Validating IPv6 checked or unchecked in Network Adapter Properties
My Requirement is to uncheck IPv6 if it is checked or if unchecked then display already unchecked.
I tried below code but it's not giving any output nor any error.
$IPv6 = Get-NetAdapterBinding | ...
1
vote
1
answer
1k
views
Powershell script to capture Screenshot
Don't want to use third party tool and module.
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate("https://www.google.com")
$ie.FullScreen = $true
...
2
votes
1
answer
2k
views
Capture batch output and save it in TXT File as log
I'm running powershell script with batch file.
My requirement is:-
display the output in batch cmd and at the same time save output in TXT file. Note, as of now output getting saved in txt file but ...
0
votes
1
answer
89
views
Exception calling "CopyFolder" with "4" argument(s): "The 'destUrl' argument is invalid."
I'm trying to copy local drive folder to targeted folder in online one drive but getting above error.
Below is the code tried: -
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\...
0
votes
0
answers
467
views
Delete a specific Computer from Active Directory without using AD Module - PowerShell
I am running PowerShell on my own computer that is connected to the domain.
I want to contact the Active Directory of my domain, check if there is an entry for this computer and if yes, delete that ...
0
votes
0
answers
138
views
Run-SCCMClientAction : Connecting to remote server DD4 failed with the following error message
I am running below script on my system to perform all sccm client actions trigger and getting below error.
Run-SCCMClientAction : Connecting to remote server DD4 failed with the following error ...
1
vote
1
answer
717
views
Export-CSV column/row value as filename
I've got a bunch of csv files that each look like this:
DD-L-1_test.jaun.Csv
Parameter, Version, Status
OS, 21H2, Compliant
Chrome, 107.1.1, Compliant
DD-L-2_test.smith.Csv
Parameter, Version, Status
...
1
vote
1
answer
295
views
The property 'AcceptButton' cannot be found on this object. Verify that the property exists and can be set
Want to store selected value in combobox in a variable $x, $y and $z but getting below error.
The property 'AcceptButton' cannot be found on this object. Verify that the property exists and can be set....
0
votes
1
answer
297
views
Form with Input Window, where a mechanism shall check if data has been entered
I need it to not close when user press enter or exit so that it mandate for user to make entry for all three box. I am new to powershell so I might be sounding akward but I can't find a good solution ...
0
votes
0
answers
147
views
IOException ERROR in Add-Content command Powershell
Objective:
Read audio files in a folder and generate a text file with the audios logs information.
When the audio totals line is going to be added to the text file, the Add-Content command shows an ...
0
votes
1
answer
813
views
Powershell operation with negative numbers
I did a search but only found answers related to excel.
Objective :
Calculate the difference between the original audio LUFS values and the user defined LUFS value. Both values are negative and I use ...
0
votes
1
answer
134
views
Command to eliminate blank lines in text file changes special characters
The command to eliminates the blank lines correctly, but it is changing the special characters in the text file.
Command:
$linblk = [System.IO.File]::ReadAllText("C:\Users\$env:username\Desktop\...
0
votes
1
answer
4k
views
Remove the first three lines in a text file
The script generates a list of Musics that will have their LUFS values normalized, however, first I need to eliminate the header from this list. The header contains three lines: The first line is ...
1
vote
1
answer
970
views
Powershell commands not working correctly via batch file
The script receives a parameter sent by the batch file, reads a Music Logs file and generates a list with a header and two columns containing the Music name and the LUFS value of each music, according ...
0
votes
0
answers
89
views
Windows server manager got uninstalled after deactivating windows power shell ISE (Windows server 2016)
After removing Windows Powershell ISE feature, the server manager became unavailable until reenabling/activating Powershell ISE. any help on how to remove it without affecting server manager
4
votes
1
answer
19k
views
Run powershell script, as administrator, via batch file with parameter passing
When I run the script, without an administrator, via batch file it passes the parameter, but when I run the script, as an administrator, it does not pass the parameter.
I tried the command from the ...
0
votes
1
answer
474
views
Remove spaces after file extensions in txt file
I need to remove from my List.txt, everything after the file extension, keeping the extension.
I tried unsuccessfully to use the commands in the links:
how-to-use-powershell-to-remove-space-from-the-...
1
vote
1
answer
740
views
Delete files in a folder based on not being in a List.txt
Objective:
Delete audio files in a folder that are not listed in the List.txt file
Reading the List.txt to compare with the files in the audio folder and deleting the files that are not listed in the ...
0
votes
1
answer
18
views
Column in custom report disappears
Script Purpose:
Read audio files and create a Custom report with the name of the songs and the LUFS value of each one.
Problem:
When a song name is too long, the LUFS Value column disappears from the ...
0
votes
1
answer
115
views
Change names within a text file
I have mixed music projects, where the software generates a txt file list of the songs in each project. The problem is that the list is generated with only the first 36 characters of the name of each ...
0
votes
1
answer
156
views
Duplicate Output Windows Updates Information
The script generates the information of the updates made in my Windows. When the final Get-WuaHistory command is executed,
records appear duplicated.
I was not successful with the information in the ...
0
votes
1
answer
33
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
581
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
59
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
662
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
622
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
1k
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
107
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
845
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
808
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
6k
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
1
answer
105
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
890
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
2k
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
196
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
469
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' - ...