9 votes
Accepted

Powershell Windows Service Deployment

Your code and overall logic look good. In general the areas of improvement I see are There are some things you are inconsistent about, e.g., function parameters You are sending notification ...
Matt's user avatar
  • 2,568
8 votes
Accepted

Power-Guessing The Number

Needs more variables I see plenty of integer constants. They define the upper and lower bounds of the game. Let turn those into variables and define them. Makes the game easier to make changes. <...
Matt's user avatar
  • 2,568
8 votes

Power-Guessing The Number

I have three points to make: GetNumber: The naming indicates it may be for integer conversion. While the truth is far from that, renaming might be a good idea. ...
Quill's user avatar
  • 11.9k
8 votes

Delete folder if it exists in PowerShell

It is better to use pipeline syntax. If there are no files, then nothing will happen: Get-ChildItem $folder -Recurse | Remove-Item
Max's user avatar
  • 81
8 votes

Remove known Excel passwords with PowerShell

Once you've found the right password and moved the file, then there is no need to try the rest of the passwords on it. You can break out of the loop with a break ...
Dangph's user avatar
  • 1,683
7 votes

MD5 hash comparison for two folders

Better is subjective but I will try and improve the code your have here to make it more robust and scalable. I will try to cover areas of improvement or focus and bring it together in the end. A lot ...
Matt's user avatar
  • 2,568
7 votes
Accepted

Powershell to quickly ping a number of machines

Want to start of with I am new to workflows as well. For the most part your code is solid. You should see a couple of suggestions that would actually improve performance especially if you are running ...
Matt's user avatar
  • 2,568
6 votes

Find related groups among list of users

Purposeful PowerShell Help I see that you have some comments in your script. Those for the most part would be hidden inside the script and the only way someone would see them is to open it. This may ...
Matt's user avatar
  • 2,568
6 votes

Adding some properties to an Active Directory user

Disclaimer: I never wrote code like that, I do not see a reason to do it and I discourage everyone to do it. This however may be seen as nothing else aside of a preference. But what are you trying to ...
Bruno Costa's user avatar
  • 5,566
6 votes

PowerShell script to create Excel spreadsheet from HTML file

Your code looks fine. Just some notes: Excel The main weakness of your design as I see it is its reliance on the Excel application. Since you say robustness is important, Excel would be the main ...
Dangph's user avatar
  • 1,683
5 votes
Accepted

Get AD Users' Latest Last Logon Dates across Multiple DCs

Aliases You're used to my reviews by now so you're probably tired of me saying this, but avoid aliases and abbreviations (% vs ...
briantist's user avatar
  • 1,799
5 votes

Sherlock is going against the Beast with PowerShell

I'm no powershell expert but if spaces sprinkled around here and there would make the code more readable. So instead of this: ...
ChrisWue's user avatar
  • 20.3k
5 votes
Accepted

Cleanly setting ACLs

To streamline the permission handling you may want to wrap ACE creation in a function and set the ACL just once at after all ACEs were added: ...
Ansgar Wiechers's user avatar
5 votes

Batch script to make folders hidden

I am glad you asked your question here. I'm hoping to explain why what you are trying to do is a bad idea. I cannot speak much for improving your batch as that is not my strong point but that should ...
Matt's user avatar
  • 2,568
5 votes
Accepted

FizzBuzz: A PowerShell Story

Your code looks good to me. I like how it takes pipelined input. That is pretty elegant. You don't need the Position=0 here: ...
Dangph's user avatar
  • 1,683
5 votes
Accepted

Query AD and build CSV based on certain user object properties

There are several changes I would propose here. I will try and tackle them one an a time. I will include some snippets as we go along but the end will contain the whole code. Redundant call to Get-...
Matt's user avatar
  • 2,568
5 votes
Accepted

Creating a portable encrypted credential store

I don't know enough about handling credentials to know whether the overall concept is sound, so I will ignore that aspect. I do have the following suggestions regarding the details of your code. Use ...
alx9r's user avatar
  • 166
5 votes
Accepted

Populate Comboboxes with Hashtables using PowerShell

The first thing to observe is that the five pieces of code are identical except for two parameters that are varying. We can capture the common the code in a function (let's call it ...
Dangph's user avatar
  • 1,683
5 votes
Accepted

Settings JAVA_HOME with Powershell

For a beginner script there are some There might be more to cover but there are a few things here that could improve the script. Variable and function naming In general functions and cmdlets should ...
Matt's user avatar
  • 2,568
5 votes
Accepted

Normalize video filenames and move files to destination directory

Get-ChildItem -include *.ext1, *.ext2 instead of Where Use pipelining via | (in direct ...
wOxxOm's user avatar
  • 1,952
5 votes
Accepted

Arp-spoof check in PowerShell

split and spread to variables: $IP, $SubnetBits = $Subnet -split '/' your user-function invocation with parentheses is incorrect and works only for single ...
wOxxOm's user avatar
  • 1,952
5 votes
Accepted

Powershell script to verify Linux-generated md5sum file

here are a few changes i would make. [grin] the ideas ... use Get-Content instead of ReadLines() the speed difference is not ...
Lee_Dailey's user avatar
5 votes

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

As pointed out in a comment from @Lee_Daily, reinventing the wheel from an interpreted language like PowerShell will be slower than a native implementation. If your primary concern is speed, use the ...
HackSlash's user avatar
  • 382
4 votes

Delete folder if it exists in PowerShell

This will delete an empty folder as well and still propagates errors if files cannot be deleted ...
arberg's user avatar
  • 141
4 votes

Powershell Script for setting DHCP reservation description & host value

Very impressed with your formatting and spacing. Top notch to see that in practice. I see a couple areas that could be improved and I see at least 2 problems. Variable Expansion in Strings Variables ...
Matt's user avatar
  • 2,568
4 votes
Accepted

Grouping all mathematical results using a number sequence with basic math operators

About performance (there's a good article to get your started: Slow Code: Top 5 ways to make your Powershell scripts run faster); I apply that advice as follows: Problem #1: Expensive operations ...
JosefZ's user avatar
  • 504
4 votes
Accepted

Bush wanderer console game

I like it, I learnt a few things about objects from this. I also really liked the board size can be easily changed. Immediate Collision When playing I noticed the Dragon was allowed to start in the ...
xXhRQ8sD2L7Z's user avatar
4 votes
Accepted

Adding some properties to an Active Directory user

I think that's fine. The dot operator is an operator like any other, so you can line it up if you think that will improve readability. It's particular useful for "fluent" style method calls: ...
Dangph's user avatar
  • 1,683
4 votes
Accepted

Getting NTFS permissions of all shared folders on the local machine

The only way to improve the speed of the script is to drop the usage of Excel as a COM-object altogether. It is considered bad practice. And it is not possible on servers where Excel is not installed. ...
Adamar's user avatar
  • 246
4 votes

Using Powershell to Copy Files to Several Locations

Simple program at first glance. I am glad to see some documentation there that explains what the code does. This is a good and important practice. Set-Location This is the only real problem I see ...
Matt's user avatar
  • 2,568

Only top scored, non community-wiki answers of a minimum length are eligible