Skip to main content

Questions tagged [powershell]

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and CIM enabling management of remote Linux systems and network devices.

Filter by
Sorted by
Tagged with
2 votes
1 answer
56 views

Powershell - Trying to streamline a Get-Service Command

This is part of a larger script but, I feel like this part could be streamlined a bit. The code currently works but I feel like doing a Get-Process call twice is ...
4 votes
1 answer
429 views

Script to backup data to specific USB Drive

I have a script and I was looking to have it reviewed to see where I should improve it. Our need: We need to backup a folder every day to a specific USB drive. There may be multiple USB drives ...
0 votes
1 answer
71 views

Construct URLs out of filenames of zero-byte images and open them in Firefox for re-downloading

It's a problem with FlashGot: it sometimes download zero-byte files. I think it's because I didn't use something like DownThemAll! to limit the number of concurrent downloads, but I wrote this script ...
0 votes
0 answers
32 views

Upload/download files from/to Discord channel based on last write time

I have created a script which does the following: Compare the last write times between... local save files for the game Valheim and remote save files (Valheim) on a discord channel where I exchange ...
0 votes
0 answers
24 views

Fastest way of finding if current user has access to a folder with Powershell

I have a Powershell script that selects a random file in a lab environment and then reads, writes, creates, and deletes files to simulate a live environment. This lab also includes folders that I don'...
3 votes
1 answer
103 views

Listing first 50 big files in directory and print relative paths and sizes

I use this Powershell command to recursively list first 50 big files in current directory and print relative paths and sizes in MiB. : ...
3 votes
1 answer
59 views

PowerShell Script for Parsing JSON PyPI Package Data and find the latest version

Following this post, I have a PowerShell script that aims to interact with the Python Package Index (PyPI) to find the latest release of a specified package that is compatible with the current Python ...
1 vote
1 answer
236 views

Intune Remediation script to uninstall 7-Zip

I just wanted to have some advice on those remediation scripts; what do you think? The idea is to detect every 7-Zip installed on the computer and search for those not up to date and uninstall them. ...
3 votes
1 answer
61 views

Powershell script that directly executes python script

Wrote this script after having some problems with clients on Win10 and consequent necessity to ship ultra-bloated .exe file of Python project over the Web to them. This is my first try to write ...
3 votes
1 answer
46 views

Comparing a set of parameters contained in two separate strings in Powershell

I have a situation where I need to compare two strings with each other in a foreach loop that potentially run over millions of rows of data. The two strings will always contain between 1 and 12 ...
5 votes
1 answer
3k views

Gracefully shutting down a HttpListener

I have worked out a code for graceful shutdown of a httplistener. However, I am not sure if its foolproof. Below I provide c# code and the powershell (v3.0) scripts I've used to run my tests... C# ...
1 vote
1 answer
52 views

Find all unique file owners through Powershell in an NTFS file system

I'm trying to find all unique file owners in an NTFS file system. Getting the number is fairly straightforward, but my current approac is very inefficient: ...
1 vote
1 answer
99 views

How to tune my powershell script for best practices?

I have written a script for CVE-2023-24932 like below. But I want to improve my script. I am open to new ideas. Here is my script: ...
1 vote
0 answers
30 views

Powershell function output as [pscustomobject]

I am currently working on a function to check for active SQL Server connections. While the function is functional, I find its implementation a bit verbose. Could you provide suggestions or ...
2 votes
1 answer
45 views

Copying data from a network share to another

The code below copies large amount of data. It does so in 2 steps. I was wondering if both step1 and step2 can be done in parallel. ...
3 votes
1 answer
330 views

Enum in PowerShell Class

I am playing with learning PowerShell classes, and I have a validation situation that kind of lends itself to Enums, as shown in the first example. With Enum ...
7 votes
2 answers
4k views

PowerShell - fast remove a directory with 10,000+ files

I am sick of File Explorer's super slow deletion speed, so I tried to write a PowerShell script to make deletion faster, and while it does its job, its speed isn't as high as what I intended it to be. ...
5 votes
2 answers
407 views

Powershell Export function to create environment variables with bash syntax

A lot of the time when working in DevOps, documentation and code snippets from colleagues will be based on bash. Most of those same commands work seamlessly in PowerShell; but setting environment ...
9 votes
0 answers
1k views

Tree for PowerShell

For anyone reading this old question, this module has evolved and improved a lot since then. It has been fully rewritten in C# and uploaded to the PowerShell Gallery! If you would like to try it out: <...
9 votes
5 answers
19k views

PowerShell script to Find and Replace in Word Document, including Header, Footer and TextBoxes within

I have written a PowerShell script to find and replace text within the whole document, including in the Headers and Footers as well as inside TextBoxes within the ...
0 votes
0 answers
32 views

remote script execution

I have a series of scripts that I need to run in a DevOps environment; certain routines cannot be executed directly within a session and yet still need to be supported. The following script is what I'...
1 vote
0 answers
269 views

Java version switcher in PowerShell

I have written a command-line tool to switch between different java versions, and as this is my first larger PowerShell script, I would like to get some feedback on the code. The powershell file ...
0 votes
1 answer
42 views

Powershell script real-time monitoring via Windows Service

I'm using a script to monitor a file. When a pattern is detected, it will send an email to notify someone. I am creating a Windows Service via NSSM. My question is : How can I improve performance of ...
1 vote
0 answers
264 views

A big prank using VBScript

So, I have made a BIG prank in VBScript. First part is to prank with a Dummy HTA splash screen using an encoded PNG image inside it (Not included) and kill all windowed processes+explorer and keep it ...
2 votes
1 answer
153 views

Powershell file parsing

I am using Powershell 7. We have the following PowerShell script that will parse some very large file. I no longer want to use 'Get-Content' as this is to slow. The script below works, but it takes a ...
2 votes
1 answer
12k views

Powershell to Convert HTML Table to Array of PSCustomObject

I created the below script to sent a request to a website, then convert the table in the results to an array of PSObjects which I can work with in PowerShell. This uses some nasty hacks (e.g. using a ...
4 votes
1 answer
690 views

Getting enum values of Pseudo-Enum classes

By "Pseudo-Enum" classes I mean cases where someone's used a class with public static properties to emulate enum behaviour; e.g. as described here. Per the example below, this is useful for classes ...
4 votes
1 answer
1k views

Fetch specific data from nested JSON-file, then append it to a CSV-file

I have written a PowerShell-script, which reads specific data-pieces out of a given JSON-file. Then reassembles the read data. Finally prepends the data to a existing CSV-file by adding it to the top ...
1 vote
0 answers
28 views

ADO wiki stats generator charting

I'm planning on adding an automated process to generate some stats once a week from a git repository, generates a markdown file with some stats, but looking for some suggestions for generating some ...
1 vote
1 answer
833 views

Script to copy Egde-Chromium browsing history from a remote machine. Try-catch, custom object building

There are some Kiosk machines for people to take a survey. The survey is running by a 3rd party, so no way to get the data from them. To measure how much machines are in use I wrote a script to pull ...
2 votes
1 answer
106 views

Any issue with this as a password generator?

Was trying to create a password generator like the one Bitwarden has... Curious if anyone sees any issues with this? (wordlist shortened for readability) There perhaps there's a more efficient way I'...
1 vote
0 answers
81 views

Powershell Outlook Email Security custom classes

This provides custom classes to work with Outlook 2016's email security settings in trust center. Included are some top level functions to list outlook profiles, retrieve the data from a given profile,...
1 vote
0 answers
457 views

Find directories and files matching certain pattern and copy them with powershell

I need to recreate project folders containing all article numbers acquired from a list. It's searching for article names in the foldernames and inside the folders. If the directory is found, it will ...
0 votes
1 answer
120 views

Powershell duplicate image scanner

So I have made this Duplicate image scanner using powershell. It will operate using the SHA256 hashes of the files. Any tips or suggestions on making this more dynamic/robust/efficient or adding new ...
4 votes
0 answers
53 views

Printer install script

I am attempting to clean up my code as best I can, but I am new to powershell and would like other's opinions on if there is anything else I can clean my code up with and any tips to overall improve ...
0 votes
1 answer
69 views

PowerShell to query SQL database with a string from a filename

I am trying to write a PowerShell script that will check a folder for any files and then for every file it will grab part of the filename and check it against the SQL database. If it found a match, it ...
2 votes
0 answers
1k views

Uninstalling Erlang and RabbitMQ, using Write-Verbose to ensure sequencing

I'm new at PowerShell and I like it. I had the change to write a script that uninstall Erlang and RabbitMQ and I want the same script to then remove the Erlang folder and the RabbitMQ folder. But ...
3 votes
3 answers
2k views

PowerShell script to convert .reg files to PowerShell commands

This is a PowerShell script I wrote a while ago that converts Windows Registry files to PowerShell commands(New-Item, Remove-Item...
0 votes
1 answer
145 views

Compare hostnames and leases between CSV and DHCP info

I have 3 nested loops and they do the following: Get scopes from DHCP Get hostnames from csv file Compares hostnames and leases, matches are added to a hash table There are 5 DHCP servers, 100's of ...
-1 votes
1 answer
108 views

Is there a better way of creating this small guessing game in PowerShell? [closed]

I have a guessing game in PowerShell trying to practice the while statement. I found this on the internet on someone's repo. I have a feeling it can be shortened but maybe I am wrong. This is pure for ...
0 votes
1 answer
84 views

PowerShell function for provisioning a new Active Directory user

I created a function for creating a new user in AD, assigning an o360 license and enabling mailbox, however, my code is very chaotic and I do not have a much experience with PowerShell. Could you ...
1 vote
0 answers
262 views

Veeam automation backup script in Powershell

I created a simple script to monitor the backup process for veeam, script accept only drives that should be on current days (to avoid override of data), monitor 2 backup jobs. Definitely could be done ...
1 vote
1 answer
89 views

Powershell script to check for processes on remote systems and rename/copy files

Processing a set of conditions with 'Continue' I found the following more readable, opposed to trying to parse out if/elseif. What are your thoughts about this? Is there a better way? What The Code ...
3 votes
1 answer
383 views

Conway's Game of Life in Powershell

I'm learning PowerShell for professional development, but decided to do a bit of a silly project to help learn scripting in more depth, and chose Conway's Game of Life. This is the first PowerShell ...
1 vote
0 answers
224 views

Batch/Powershell program to retrieve system info

This is my first time coding! My intent for this program was to be able to give my technicians a flash drive that will pull system info and email it to me. Currently everything is working, but I was ...
0 votes
1 answer
379 views

powershell script for creating a Domain Controller

I don't have a lot of experience creating/managing an active directory environment. This will be more of a lab environment where a solution could be tested. It will not have lots of regular users etc, ...
1 vote
1 answer
151 views

PowerShell - calculate occurences of Friday the 13th between (including) two given years with builtin and without builtin

It's me again, talented programming beginner fast-learner, so I have overcomed yet another self-imposed programming challenge, I have developped two algorithms to calculate occurrences of Friday the ...
2 votes
1 answer
314 views

Powershell SMTP report with attachment issues needs corrections

I created this tiny script to full fill a repeated request from audit. I want to expand it but ran into an issue with file creation. This code will create the ...
1 vote
0 answers
234 views

File Deletion PowerShell Script

I would like your opinion of my PowerShell script for file deletion. Do I follow conventions, do I use some anti patterns? Every critique is welcome! This is an example of a report log: This is the ...
3 votes
1 answer
1k views

PowerShell script binary-decimal-hexadecimal-ipv4 convertor

This is a fully functional PowerShell script I wrote not long ago that converts data (numerical data) among 4 data formats: binary, decimal, hexadecimal and ipv4. It supports 12 conversions, it can ...

1
2 3 4 5 6