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 ...
-3
votes
0answers
19 views
Extracting and modifying administrator accounts listed in a CSV file
I created an automated process for a report that I have to generate every month. The script imports a CSV then filters out the administrators and the operating systems. Then I add a Unique Account ...
3
votes
0answers
39 views
Powershell script that reads Outlook emails and exports results as .csv
I wrote my first powershell script. It reads through all the emails in a folder and exports some of the data as a csv file. I'm happy with the way it works but I plan to share it with co-workers, so ...
3
votes
1answer
46 views
Filtering and processing computers listed in a CSV file
I am trying to make my script run a lot faster. I have a csv that has about 330k of lines on it that I plan on running my script with and it has been taking an extremely long time. I just did ran the ...
1
vote
0answers
22 views
Easily Create XML within PowerShell
The purpose of this PowerShell function is to make it simpler to output XML in a given format. For my use case, that XML did not have a schema associated, so I've not implemented any namespace logic; ...
2
votes
0answers
21 views
4
votes
0answers
29 views
PowerShell Supports Paging
I've not played with SupportsPaging before, so wanted to knock up some demo code & get feedback on whether my implementation is OK, or if I've misunderstood ...
2
votes
0answers
56 views
Creating & reading CSV with system own tools
There are lot libraries for creating/parsing CSV but how about not using any of them and instead use Windows own tools like PowerShell?
I thought I'll try and create some extensions for that purpose ...
1
vote
0answers
44 views
Excel query within PowerShell
I am currently using the following query to add a specific row (with 10 columns) from an Excel spreadsheet (~1500 rows and hosted on SharePoint - I've also tested locally with the same issue) to an ...
2
votes
1answer
80 views
Escaping characters in a WMI Query
I've knocked up this code to allow me to query for specific service names using PowerShell.
I'm after the executable (PathName) for the service, so the ...
3
votes
0answers
44 views
Restart a service and check its status
I have written this script to stop and start a specific service and check if it was able to load and unload applications tasks correctly, by checking a status in application log. Also it writes a log ...
2
votes
0answers
31 views
Watermark and join videos in bulk using ffmpeg
I have this batch file using ffmpeg to add a logo to my videos and then add an intro but it's taking anywhere from 10 hours to a day depending on how many I have to watermark, is there a more ...
2
votes
0answers
55 views
Script testing a PDF making server
The script tests a server rendering PDFs. The server is running as a Windows service.
The script does the following:
Prepare the test
configure server
export script variables to xml
copy input
Run ...
7
votes
2answers
107 views
Remove known Excel passwords with PowerShell
I have this PowerShell code that loops through Excel files in a specified directory; references a list of known passwords to find the correct one; and then opens, decrypts, and saves that file to a ...
6
votes
0answers
61 views
Powershell menu-driven text file viewer / presenter tool
This is a simple Powershell script to provide menu driven manuals and standard operating procedures.
Sops and mans with the extension .sopman.txt will be loaded.
...
3
votes
1answer
59 views
Delete lines from a CSV file that contain fields listed in a text file
I wrote a powershell script to compare words from a text-file with a csv-column. If the word in the column matches, the line is deleted.
...
7
votes
2answers
78 views
Convert a password to a phonetic string for end users
As much as I hate it, sometimes providing passwords to people has to be done electronically. When I do that I try to remove any ambiguity that might be created by the font, user etc. and provide a ...
3
votes
0answers
71 views
Replicating Bash's command substitution in PowerShell
I want to be able to use Bash's ^search^replace functionality in PowerShell, the closest I can come is with this function and linking it to the alias ^.
So in Bash I would do:
...
5
votes
1answer
65 views
Normalize video filenames and move files to destination directory
I have written a powershell script that will scan a directory for any *mkv, *.mp4, *.avi ...
4
votes
1answer
84 views
Find and replace database string in all Web.configs across a stack
I was tasked with this assignment with almost no time and I cannot stand up a new environment to test this. The risk is pretty high with what is the request is for so I'm asking for as much peer and ...
0
votes
0answers
40 views
Running a script and analyzing the output with PowerShell
The task of the script is to analyze the output of a CLI program and finding specific lines.
...
3
votes
0answers
88 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# ...
2
votes
0answers
55 views
Inefficient PowerShell function for checking group membership
I use the following function in a PowerShell script to check and - depending on the value of the $Action - either add or remove an Active Directory User Object from ...
10
votes
1answer
139 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
136 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
259 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....
7
votes
1answer
465 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 ...
4
votes
0answers
75 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 https://stackoverflow.com/a/40871162/361842).
Here's my workaround:
...
3
votes
1answer
461 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
76 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
68 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 ...
4
votes
1answer
84 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 ...
2
votes
0answers
61 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
62 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
71 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
168 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
814 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
68 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 ...
5
votes
2answers
130 views
Getting NTFS permissions of all shared folders on the local machine
How can I improve the speed of the script?
...
6
votes
1answer
524 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
153 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
109 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
118 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 ...
6
votes
1answer
174 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
138 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 ...
1
vote
4answers
104 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
47 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 ...
2
votes
1answer
230 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
600 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
90 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
142 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 ...