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
1 vote
3 answers
100 views

I use PowerShell to retrieve the last two application logs with event ID 654 and calculate the time difference between them. If the time difference between the two logs is more than 30 minutes, I will ...
Cell-o's user avatar
  • 335
2 votes
0 answers
46 views

I'm currently updating a ping script I maintain at work, transitioning from WinForms to WPF. Because of this I've started learning about and incorporating runspaces to keep the GUI responsive during ...
K_P's user avatar
  • 21
0 votes
1 answer
490 views

I've been experiencing frequent issues with my Windows operating system, requiring me to manually run various system health and repair commands (such as DISM, ...
Foad's user avatar
  • 379
2 votes
1 answer
107 views

I'm a support analyst/help desk technician by trade. Here's a little PowerShell script I've cobbled together over the years to harvest details of Windows client and/or server platforms. I use this ...
Pendraig's user avatar
2 votes
1 answer
95 views

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 ...
RKillcrazy's user avatar
3 votes
1 answer
161 views

I use this Powershell command to recursively list first 50 big files in current directory and print relative paths and sizes in MiB. : ...
SebMa's user avatar
  • 131
2 votes
1 answer
678 views

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. ...
S. Me's user avatar
  • 23
3 votes
1 answer
84 views

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 ...
Foad's user avatar
  • 379
3 votes
1 answer
112 views

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 ...
MaxiMaxi's user avatar
  • 177
1 vote
1 answer
79 views

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: ...
Tanaka Saito's user avatar
3 votes
1 answer
63 views

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 ...
Tanaka Saito's user avatar
2 votes
1 answer
68 views

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. ...
Newborn's user avatar
  • 21
5 votes
2 answers
493 views

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 ...
JohnLBevan's user avatar
  • 1,419
2 votes
1 answer
140 views

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: ...
Cell-o's user avatar
  • 335
1 vote
1 answer
64 views

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 ...
Cell-o's user avatar
  • 335
3 votes
1 answer
194 views

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 ...
Cell-o's user avatar
  • 335
4 votes
1 answer
2k views

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 ...
michael.zech's user avatar
  • 5,042
4 votes
0 answers
65 views

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 ...
RyanHallCoder's user avatar
-1 votes
1 answer
156 views

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 ...
john's user avatar
  • 15
2 votes
1 answer
156 views

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'...
meowsoftly's user avatar
0 votes
1 answer
97 views

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 ...
Rudixx's user avatar
  • 1
0 votes
1 answer
116 views

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 ...
Alex Karapetian's user avatar
9 votes
0 answers
1k views

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: <...
Santiago Squarzon's user avatar
1 vote
1 answer
119 views

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 ...
Mike Q's user avatar
  • 113
3 votes
1 answer
480 views

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 ...
Carcigenicate's user avatar
0 votes
0 answers
270 views

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 ...
Boogershut's user avatar
0 votes
1 answer
426 views

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, ...
whoami's user avatar
  • 175
1 vote
1 answer
909 views

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 ...
user2978216's user avatar
3 votes
1 answer
1k views

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 ...
Ξένη Γήινος's user avatar
3 votes
1 answer
112 views

I am running a PowerShell script that shows disk usage for drives into HTML reports. While this works quite well it has a problem on some file servers with a massive amount of files. It can sometimes ...
Ashley H's user avatar
1 vote
1 answer
681 views

I originally posted this on StackOverflow but was requested to post it here instead as it relates to optimization/performance of the code rather than a specific problem. TL;DR: Get-Random produces an ...
Tanaka Saito's user avatar
0 votes
1 answer
167 views

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 ...
feelsgood's user avatar
2 votes
0 answers
121 views

I've been asked to create some code to help automate the loading of data into a system based on employee data in a spreadsheet. However, the data isn't clean, so some people may have no manager, some ...
JohnLBevan's user avatar
  • 1,419
2 votes
1 answer
357 views

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 ...
StormySkies's user avatar
3 votes
3 answers
3k views

This is a PowerShell script I wrote a while ago that converts Windows Registry files to PowerShell commands(New-Item, Remove-Item...
Ξένη Γήινος's user avatar
0 votes
1 answer
124 views

I am building a PowerShell class based tool that works with XML files of as much as a few hundred Kb size, and as many as a hundred of these files. I have extensive validation code that is time ...
Gordon in Ukraine's user avatar
1 vote
0 answers
2k views

I found a project that aims to implement a CLI calculator app in as many different languages and ways as possible. Having a little experience in PS, I tried my hand at it. The requirements are as ...
mindoverflow's user avatar
0 votes
1 answer
151 views

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 ...
avarice's user avatar
  • 131
7 votes
2 answers
4k views

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. ...
Ξένη Γήινος's user avatar
1 vote
1 answer
174 views

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 ...
Ξένη Γήινος's user avatar
0 votes
0 answers
2k views

I am a newbie in programming, but I do have potential, I am using PowerShell to hone my skills, I have written a simple function to sort strings consisted of numbers humanly (i.e. in a order like 1 2 ...
Ξένη Γήινος's user avatar
2 votes
0 answers
360 views

I am extremely new to programming, and I am a really fast learner if I am interested, I have only started using PowerShell in less than a month, to improve my programming skill, this is a script I ...
Ξένη Γήινος's user avatar
1 vote
0 answers
822 views

The title says it all, I have written two scripts to calculate dates to test my abilities in programming, one from scratch, without [DateTime], New-TimeSpan and even [math]::Ceiling, and it's really ...
Ξένη Γήινος's user avatar
1 vote
1 answer
204 views

Link to problem: https://www.codewars.com/kata/5539fecef69c483c5a000015/train/powershell I have a working solution in Codewars but my solution is slow for some reason and I need to improve the ...
Gringo Jaimes's user avatar
1 vote
1 answer
119 views

I would like your opinion on my Remove-Files PowerShell function. It is used in my File-Removal-PowerShell-Script. It is designed to be very flexible so a script ...
Zoran Jankov's user avatar
3 votes
0 answers
256 views

I've written a script that gets a list of all groups in AD along with a few specific properties for each group (DistinguishedName, CN, Type, and Description). Then it goes through each group and, for ...
TylerH's user avatar
  • 131
3 votes
0 answers
902 views

I have created a PowerShell script that will call a REST API and then for each node returned, add the data into a database table. This particular endpoint only returns ~600 records worth of data, ...
Ross's user avatar
  • 337
3 votes
0 answers
330 views

I have an AD Group I keep up-to-date based on a CSV file. Users not present in the file should be removed from the AD Group. ...
Peter9001's user avatar
4 votes
2 answers
179 views

I am still learning PowerShell and I would like your opinion on my log writing function. It creates a log entry with timestamp and message passed thru a parameter Message or thru pipeline, and saves ...
Zoran Jankov's user avatar
2 votes
1 answer
80 views

I am still learning PowerShell and I would like your opinion on my folder deployment PowerShell function. It basically check if a defined folder exists and creates it if it does not and writes it ...
Zoran Jankov's user avatar

1
2 3 4 5 6