Setting functions into function parameter in Powershell

gisliScriptingLeave a Comment

There are multiple ways to assign parameters into a function it makes sometimes the function simpler but can it make it unreadable or even the code causing errors. Now there are two examples bellow and I just wanted to show you that setting function into a function is possible, not that you would use it unless you have some awesome scenario. Here is one that has just one parameter and ConverTo-SecureString function in the function itself, the code seems to … Read More

Default value in Powershell function parameter

gisliScriptingLeave a Comment

Updated : I was asked if there was a use case for this and I added an example on how to create user with some of the default values. Someone asked me if there was a possibility to have a default value in a function parameter because the code the person wrote was to have if else statement in the code as you can see in this specific code View the code on Gist. But better way to set default … Read More

GoLang starting getting creative

gisliProgrammingLeave a Comment

GoLang or Go is a programming language maintained by Google and was created by Robert Griesemer, Rob Pike and Ken Thompson who have done a great impact on the programming language usage in the world, such as C and Java.  Go was in fact a experiment at Google that somehow where able to create such an awesome programming language that they figured that they should just release it. Anyhow Go language does force programmers to behave in a logical way … Read More

Powershell Parallel Processing

gisliScriptingLeave a Comment

Parallel processing is where you can iterate more commands at the same time. In powershell you basically run through step by step procedure where you do something, but if you run parallel processing you can run more than one steps at a time. For instance if you are enumerating through multiple servers like doing a WMI query from servers, you would in fact run one server at a time, but if you use parallel processing you can run WMI query … Read More

Simpler techniques with Powershell

gisliScriptingLeave a Comment

There are ways to do write code in Powershell much simpler and of course if you have been using Powershell and you feel comfortable with these different types of commands, it could be little bit hard to learn a new ones that do the same, for instance if you are writing a foreach command then there are few ways to do it. Lets say that I have an array with a few cars and I want to iterate through the … Read More

Simple way to add class to Powershell

gisliScriptingLeave a Comment

Current version of Powershell allows you to add classes so you can manipulate the data when it has been added to the class. Here is a simple way to create a class, this contains only a small example code on how to do this View the code on Gist. There are alternative ways to do this such as using function and new psobjects but that might not be intended to do really professional code, so it would be a good … Read More

Pinging a User with Powershell

gisliScriptingLeave a Comment

I´m really not going to explain this much other than what this script does is basically few things. This script was created because one had asked that he wished that he could ping users like computers, I said I will create a script for that for him and here it is. Checks if the user exist in Active Directory if it does it continues Gathers all computers based on OSType Checks if the computer is online Gets events based on … Read More

WannaCry Powershell Detector

gisliScriptingLeave a Comment

As you may or may not know there is an outbreak going on with a Virus named WannaCry. There are some computers that are affected. I created a small script that checks for specific files, and if the powershell detects it, it sends an email and disables all the network cards. You can run this at startup by using GPO, so in the morning when users arrive in the office and start the computer the script will run. Here is … Read More

Create users using CSV and Powershell

gisliScriptingLeave a Comment

There have been a lot of questions on the internet about how to create users from csv so I wondered if I could just create a quick simple guide how to do this. First we need to decide what attributes we are going to implement into the CSV file, we need some required attributes such as First Name, Last Name, Display Name, Username and so on. You can run the following command to see what attributes you can add or … Read More

Linux Powershell

gisliScriptingLeave a Comment

As you may know that Microsoft has released Powershell on linux a few months ago but I have not been able to test it, so I decided to try it out. I installed Ubuntu 64bit 16.04 and tried to figure out how to install Powershell. I noticed that Microsoft has said that they have released Powershell for linux and mac but they did not mention that it was an alpha version. Anyways I ran the following command wget chmod … Read More