In this post, I explain how to create a PowerShell function to process CSV data. This allows you to reuse your code whenever you are working with CSV files in PowerShell.
CSV (Comma-Separated Values) is used by almost every technology platform that we encounter. Manipulating this data can be cumbersome if you’re NOT an Excel wizard, but PowerShell can simplify this job. For example,
To run a PowerShell script on multiple computers via Group Policy, you can work with an Immediate Scheduled Task. The main advantage over logon scripts is that you can execute your script with admin rights.
Have you ever needed to download code or a repository from Github, but didn’t want to download and install Git on a machine, create an SSH key, etc. If so, I have something that you may like.
You can find the entire function here: https://github.com/MSAdministrator/GetGithubRepository
To use this function, you will need to know the path to the Github repository (of course) you want to download. Once you have that URL, you will need to pass each piece of the URL into a parameter on the function.
For example, let’s take a URL like https://github.com/MSAdministrator/WriteLogEntry. This URL can be broken down as follows
- MSAdministrator = Owner
- WriteLogEntry = Repository
We also know that we want to download the “master” branch of this repository. The next part is that we need to gather a list of files/paths that we need to download as well. These will be passed as an array of strings to the FilePath parameter.
- Branch = Master (unless you want a different branch)
- FilePath = (Files and paths you want to download)
By default this function will always get the master branch of the repository you are wanting to download, but you can specify a different branch if wanted. Additionally, this function will download the specified files to your user profiles Module Path (C:\users\some_user\Documents\WindowsPowerShell\Modules)
To use this function, you will need to pass the following values as parameters to the function. For example, to download my WriteLogEntry repository you will need to call the function like so:
Get-GithubRepository -Owner MSAdministrator -Repository WriteLogEntry -Verbose -FilePath `
I hope that this function helps some of you who want to quickly download a Github repository without installing or using Git. If you have issues or like this function, please submit issues or fork requests to my Github.
Original Image here:
As I discussed in my previous post, you can log information to a file, but sometimes you may want to log to the Windows Event Log. To log to the Windows Event Log, you will need to use the following cmdlets:
The PowerShell function Write-LogEntry described in this post allows you to integrate logging in your scripts in a standardized way. This will help you and your script users to troubleshoot and understand the output. Read More