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 ...

learn more… | top users | synonyms

8
votes
0answers
29 views

Automating the download of a GitHub repo

This script is designed to locate and download the first repository in your sidebar on the GitHub repository page. It downloads the .zip file for that repo and saves it to the default location. I ...
6
votes
3answers
72 views

Creating a script to automate implicit remoting

Goal: I am attempting to create a script that would automatically establish a PSSession to a Windows server for implicit remoting. Problem: ...
3
votes
1answer
48 views

Batch convert txt files to xls

In this SO question I provided two answers for the batch conversion of more than 100K txt to xlsx files I suspect any automation of Excel is too slow, but would appreciate if there is a superior (i....
5
votes
1answer
55 views

Settings JAVA_HOME with Powershell

Previously in the Settings JAVA_HOME with batch post, I had created a script in bash to change my JAVA_HOME env variable. Since then, I have been trying to use more ...
3
votes
0answers
40 views

PowerShell Export-CSV with Cultural Awareness

I recently had a requirement to export data to CSV in a different culture & hit an issue (see http://stackoverflow.com/a/40871162/361842). Here's my workaround: ...
3
votes
1answer
140 views

Task based PowerShell cmdlet

I am learning about Tasks and also writing PowerShell cmdlets in C#. I found that connecting to remote machines was very slow, so I wrote this bit of code to speed it up using Tasks. I am hoping to ...
2
votes
0answers
42 views

Escape Characters for LDAP/ADSI string

Below's some code I knocked up to escape the account name to be used in creating an ADSI reference to an account (e.g. escaping $sAmAccountName before using in <...
3
votes
1answer
63 views

Gather information about computers from multiple CSV files

I created a script to import several CSV files from various sources and one CSV file with a list of systems in it. the script searches each CSV file to see if the system exist in the file and if it ...
3
votes
1answer
60 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 ...
1
vote
0answers
29 views

A PowerShell script to modify svn:externals property on certain folders

While I'm a rather experienced .NET developer, I just had a first crack at a PowerShell script. I'm not entirely new to it, but never written anything so involved. Script description and goals At ...
3
votes
0answers
52 views

Fetching certain eventIDs from servers on network.

The PowerShell script below queries the Security event log on one or more servers for events with id 4663. When trying to retrieve all audit events for event id 4663 with the following code the ...
2
votes
1answer
60 views

Downloading and updating deploymentshare applications

I'm an absolute newb when it comes to PowerShell, and this is pretty much my first real script. I'd now like to know ways to improve it and if possible to shorten the code even further. I use it ...
2
votes
1answer
129 views

Automatically remove O365 license from AD user when using powershell

As you can see I have been using multiple conditions such as if, elseif, else, but it takes ...
3
votes
1answer
275 views

PowerShell script to read line by line large CSV files

I am managing large CSV files (files ranging from 750 Mb to 10+ Gb), parsing their data into PSObjects, then processing each of those objects based on what is required. I wrote the following script ...
5
votes
1answer
49 views

Using Powershell to Copy Files to Several Locations

This code copies files to our Test server and places the executable on a file share for the tester to access. I'm new to Powershell, so I'm sure I'm not doing this in the most efficient way. Any ...
4
votes
2answers
96 views

Getting NTFS permissions of all shared folders on the local machine

How can I improve the speed of the script? ...
6
votes
1answer
129 views

PowerShell script to create Excel spreadsheet from HTML file

This script is designed to create an Excel spreadsheet from each HTML table from auto-generated index.html file. It needs to be very robust but unfortunately I ...
6
votes
2answers
126 views

Powershell cmdlet authenticating to Aerohive API

After dipping my toes in PowerShell for over a year i think it is time for creating a real cmdlet. My first mission was creating a regular PS script to take in a .csv and create a wifi account using ...
2
votes
1answer
69 views

Copying files, renaming conflicts

I wrote a script to copy a file, but this file already exists in the target directory. So, first I need to rename the original file. The script works, but a colleague did not want to use it because ...
5
votes
1answer
65 views

Powershell Interaction with Excel (Highlighting Cells)

I'm using Powershell to compare two, large csv files and output the rows which don't match. Once the two output files are made (one for the differences on each), I bring them up on Excel. Now I want ...
5
votes
1answer
81 views

Populate Comboboxes with Hashtables using PowerShell

Background This is a PowerShell program that uses XAML code from Visual Studio to create a GUI. In this program, there are various Comboboxes (Drop-down menus) used to select different features of ...
2
votes
1answer
62 views

Automation script for creating NuGet packages

I've been creating some NuGet packages recenly and to automate the process I created the following script that: reads the package id from the script name reads the package version from the nuspec ...
0
votes
4answers
69 views

powershell md5 compare too slow

I'm trying to compare several files using md5 hash with powershell 2.0. The code works, the problem is that it's to slow. It takes longer in step 3. It's about 500 files to compare. Can you see a way ...
4
votes
1answer
42 views

Babysitting a server reboot

I'm looking to improve a loop within a script that performs scheduled server restarts. Currently, I'm using a DO While loop with an exit condition within an IF statement once a counter reaches a ...
1
vote
1answer
152 views

Vigenere Cipher encryption and decryption

I wanted to make some simple functions that would be used in the encryption and decryption using a Vigenere square. ...
2
votes
2answers
407 views

Adding some properties to an Active Directory user

I was writing the below section of code which adds some user properties to an Active Directory user, and got wondering - surely we can improve the readability of this : ...
3
votes
1answer
73 views

Chain nesting XML elements

I have a scenario where I need to chain nest XmlElements, and I got a working solution using a recursive function, but I can't help but feel that it can be made better. Here's my code so far: ...
4
votes
4answers
137 views

Advent of Code Day 6: toggling lights in a grid with Powershell

I am using the "Advent of Code" series to help with my PowerShell education. The Day 6 puzzle has a 1000 × 1000 grid of lights. After processing instructions to turn on, turn off, or toggle rectangles ...
4
votes
1answer
63 views

Script to periodically Identify and act on public IP address

This script checks what the current public IP address is. The plan is for this to run every 5 minutes or so, and then change some host file configuration depending on whether we the IP is identified ...
2
votes
1answer
385 views

Create share folder, AD security group, add descriptions, and apply security to new folder

My goal for this script was to: Create new folder Create AD group FS-TESTSHARE-R Create AD group FS-TESTSHARE-RW Apply both groups to the new share folder Set full read permissions to FS-TESTSHARE-R ...
4
votes
1answer
97 views

Create share folder and AD security group and apply security to new folder

I think I'm finally done with my code and was hoping for some pointers. My goal for this script was to: Create new folder Create AD group FS-TESTSHARE-R Create AD group FS-TESTSHARE-RW Apply both ...
4
votes
1answer
65 views

Cleanly setting ACLs

So this is my full script that I've been working on. My plan is to Create New, Folder, Create AD Group FS-TESTSHARE-R, Create AD Group FS-TESTSHARE-RW, Apply Both groups to the new share folder, Set ...
1
vote
1answer
119 views

Powershell task to poll SQL database for psexec commands to run

We have a requirement for a script which polls an SQL database for scrape commands which need to be run. These commands are added to the SQL database on an ad-hoc basis. The scrape commands themselves ...
8
votes
1answer
112 views

Batch script to make folders hidden

I just wrote a simple script cmd to hide private folders by combining several scripts from the Internet. Can anyone give me suggestions for improvement? This batch file uses a password hidden by ...
9
votes
1answer
137 views

Powershell Script for setting DHCP reservation description & host value

I'm new to Powershell scripting and trying to write a script that will go through printer queues on a print server, get the print queue's port address, then compare the print queues port address to ...
1
vote
0answers
41 views

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

Not sure how to make the title smaller. I was reading the question A truly amazing way of making the number 2016 and some of the answers referred to programatically determining the answer set. What ...
10
votes
1answer
76 views

Bush wanderer console game

I had read the question: Bush Wanderer - code intended for teaching and wanted to play with PowerShell. Including the rules of the game from that same question. Bush Wanderer Task 1 ...
2
votes
1answer
569 views

Get AD Users' Latest Last Logon Dates across Multiple DCs

I was recently asked to help our Spanish BU to audit their AD for inactive accounts. Grabbing a script from online I gave them this: https://gallery.technet.microsoft.com/scriptcenter/Get-Active-...
7
votes
2answers
306 views

Power-Guessing The Number

I decided to help @Matt out a bit and ask a PowerShell question. This is a simple guess-the-number game learning how to use functions with and without parameters, and use the input and output ...
5
votes
1answer
82 views

Sherlock is going against the Beast with PowerShell

I ran into this challenge a couple of times today and thought I could tackle it with PowerShell. I refused to look at other peoples approaches to this hoping to complete it on my own. I'm sure the ...
2
votes
0answers
27 views

Non-install based customization for creating windows 7 images

Before I had access to VM's, money or had any PowerShell knowledge I made this script that would do some image customizations for me. I used physical computers and would be reinstalling the OS while I ...
3
votes
1answer
180 views

Find related groups among list of users

I have one of my first PowerShell scripts that will query a list of users in Active Directory. While doing so it will keep a tally in a hashtable that will update for every group increasing it count ...
2
votes
2answers
172 views

Powershell script to iterate through folder and restore SQL backups

I am working on a PowerShell script which will loop through a directory containing SQL Server database backup .bak files; move the files to a different location; restore each of those files to the ...
2
votes
1answer
240 views

Creating a portable encrypted credential store

There have been a few questions over on SO recently about securely storing credentials in Powershell scripts. Because ConvertFrom-SecureString uses DPAPI it makes ...
6
votes
1answer
90 views

SharePoint Online inventory

I'm creating a script to turn into a commandlet we can reuse as part of our custom PowerShell module. This works, but is very slow. I don't suspect it is anything to do with my code. I have to ...
4
votes
1answer
130 views

Delete orphaned SIDS + change to full control

I need to delete all the orphaned SIDs in the ACLs of about 20 shares (between 100GB/6TB) and change full control of users groups to other permissions (modify or read/execute). I have done this script ...
5
votes
1answer
530 views

Batch/PowerShell script that toggles the minimized state of a window

I wrote this script for a user who wants to toggle the minimized state of a window that minimizes to the tray. The user required a .bat script, so I wrote a bat + PowerShell hybrid script in order to ...
11
votes
1answer
163 views

FizzBuzz: A PowerShell Story

After reading way too much into what fizzbuzz was I though PowerShell could easily have its way with this. ...
5
votes
1answer
1k views

Query AD and build CSV based on certain user object properties

My question is about code efficiency. I recently had to write a Powershell 3.0 script which had the following criteria: It had to pull all enabled user objects from active directory It had to pull ...
1
vote
1answer
197 views

XML editing and merging

I have only started working with XML files and PowerShell. I feel that while there are many ways to accomplish the same thing that I might be doing the following inefficiently. This is all based on ...