Skip to content

Instantly share code, notes, and snippets.

#----------------------------------------------------------------------##
# Module Name : AuditServers.ps1
# Created : 11.11.2016
# Created by : Gisli Gudmundsson# LinkedIN : https://is.linkedin.com/in/gisli-gudmundsson-11a77639
# License Usage : # This code can be used for private use only
# You may modify this code and distribute
##----------------------------------------------------------------------##
Import-Module ActiveDirectory
Import-Module C:\DynamicDocumentation\Dependencies\DEPMSSQLActions.psm1 -Force
#----------------------------------------------------------------------##
# Module Name : AuditServices.ps1
# Created : 08.11.2016
# Created by : Gisli Gudmundsson
# LinkedIN : https://is.linkedin.com/in/gisli-gudmundsson-11a77639
# License Usage :
# This code can be used for private use only
# You may modify this code and distribute
##----------------------------------------------------------------------##
Import-Module ActiveDirectory
#----------------------------------------------------------------------##
# Module Name : DEPMSSQLActions.psm1
# Created : 27.10.2016
# Created by : Gisli Gudmundsson
# LinkedIN : https://is.linkedin.com/in/gisli-gudmundsson-11a77639# License Usage :
# This code can be used for private use only# You may modify this code and distribute
##----------------------------------------------------------------------#
#Import the SQL Server Powershell Module
Import-Module SqlServer
#----------------------------------------------------------------------#
#
# Module Name : DEPMSSQLActions.psm1
# Created : 27.10.2016
# Created by : Gisli Gudmundsson
# LinkedIN : https://is.linkedin.com/in/gisli-gudmundsson-11a77639
# License Usage :
# This code can be used for private use only
# You may modify this code and distribute
#
#The C# Code starts with @ sign and ends with @ sign.
$CSharpCode = @"
public class ExampleCSharp
{
public string ReturnTheString(string returnString)
{
string Combine = "Your awesome text is : " + returnString;
return Combine;
}
#------------------
# Lottery game by Gisli Gudmundsson
# Created 13.11.2016
$ApplicationName = "PowerBalls"
$MaximumBallNumber = 20
$TotalGamePlays = 1000000
$RowWinningPercentage = 16.6667
$WinningRow = 0
$YourNumbers = "10","3","9","7","8","5"
#Import the values for the users
$UserValues = Import-Csv -Path c:\UserCreation\Users.csv -Delimiter ";"#Create the user function so I will not repeat myselffunctioncreateUsers($FirstName, $LastName, $Password, $Department){
#The path for the user to be placed, in this scenario I put them in a department OU and Users
$OUPath = "OU=Users,OU=$Department,OU=Departments,DC=TSTDOMAIN,DC=COM"
#Convert the password to securestring
$AccountPassword = (ConvertTo-SecureString -AsPlainText $Password -Force)
#Create the Displayname, samaccountname, userprincipal name
$DisplayName = $FirstName+" "+$LastName
@gislig
gislig / PowershellWannaCryDetector.ps1
Created May 10, 2018 09:31
Run as service and detect if you have specific files on a users computer, was specifically created for wannacry virus
#CREATED BY GISLI GUDMUNDSSON
#GLOBAL VARIABLES
$MailTo = "admin@yourcompany.com"
$SmptServer = "yourmxserver.domain.com"
function SendInfectionMessage(){
Send-MailMessage -To $MailTo -From "$env:COMPUTERNAME" -Subject "WannaCry Infection Detected - $env:COMPUTERNAME" -Body "WannaCry Infection Was Likely Detected on Computer $env:COMPUTERNAME. Please contact Username $env:USERNAME to investigate further. The Network Was Disabled On Remote Machine" -SmtpServer $SmtpServer
@gislig
gislig / UserPing.ps1
Created May 10, 2018 09:24
Ping User on the Network
#Script created by Gísli Guðmundsson
#Created for Aron Gauti Birgisson
#Create Objects to set info about the computers who user logged on to
function setPingUser($ComputerName, $IPAddress, $User){
New-Object psobject -Property @{
ComputerName=$ComputerName;
IPAddress=$IPAddress;
User=$User;
@gislig
gislig / SimpleExample2.ps1
Created May 10, 2018 09:15
Simple Powershell Example 2
$Cars = "Tyota","Hyundai","Ford"
#Where in Array
$Cars | Where-Object { $_ -eq "Hyundai" }
#Where in Array simpler
$Cars | Where { $_ -eq "Hyundai" }
#Where in Array much simpler
$Cars | ? { $_ -eq "Hyundai" }