Skip to content

Instantly share code, notes, and snippets.

Gisli Gudmundsson gislig

Block or report user

Report or block gislig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gislig
gislig / OneParameterFunction.ps1
Last active Aug 3, 2018
OneParameterFunction.ps1
View OneParameterFunction.ps1
#ConvertTo-SecureString in the function
function CreateUser($Password){
$Secure_String_Pwd = (ConvertTo-SecureString $Password -AsPlainText -Force)
New-ADUser -Name "Tom" -SamAccountName "Tom" -AccountPassword $Secure_String_Pwd
}
CreateUser -Password "tHISIsMySecurePassword!!!"
View SecureStringIntoParameter.ps1
#ConvertTo-SecureString into a parameter, is there any logic behind it ?
function CreateUser($Password, $Secure_String_Pwd = (ConvertTo-SecureString $Password -AsPlainText -Force)){
New-ADUser -Name "Tom" -SamAccountName "Tom" -AccountPassword $Secure_String_Pwd
}
CreateUser -Password "tHISIsMySecurePassword!!!"
View NewUserDefaultParameters.ps1
#Function that contains some default values and some $null values.
function CreateUser($SamAccountName, [string]$UPN = "domain.local", [bool]$Enabled = $True, $FirstName, $LastName){
New-ADUser -SamAccountName $SamAccountName -UserPrinciplalName "$SamAccountName@$UPN" -Enabled $Enabled -FirstName $FirstName -SurName $LastName
}
#Creating a user with out the dfeaults
CreateUser -SamAccountName "Bob" -UPN "bob.com" -Enabled $False -FirstName "Bob" -LastName "Builder"
#Creating a user with the defaults
CreateUser -SamAccountName "Hugi" -FirstName "Hugi" -LastName "Freyr"
@gislig
gislig / CorrectDefaultParam.ps1
Created Aug 1, 2018
Simpler Way and in theory correct way to add parameter in a function
View CorrectDefaultParam.ps1
function DefaultValue([int]$valueParam = 10){
Write-Host $valueParam
}
DefaultValue
@gislig
gislig / WrongDefaultParam.ps1
Last active Aug 1, 2018
This is not how to define a default value parameter in a code.
View WrongDefaultParam.ps1
function DefaultValue($valueParam){
if($valueParam -eq $null){ $valueParam = 10 }
Write-Host $valueParam
}
DefaultValue
View SimpleBasic.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World")
}
View PowershellParallelProcessing.ps1
# ------------------------------- #
# Powershell Parallel Processing
#
# Written by Gísli Guðmundsson
# 2018
# ------------------------------- #
$Files = "C:\Temp\file1.txt","C:\Temp\file2.txt","C:\Temp\file3.txt","C:\Temp\file4.txt"
#Loop through the files Array
View Debug-SQL.psm1
#----------------------------------------------------------------------##
# Powershell Script Name : Debug-sql.ps1
# 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-Module C:\DynamicDocumentation\Dependencies\DEPMSSQLActions.psm1 -Force -Verbose
View AuditSoftware.ps1
----------------------------------------------------------------------### Module Name : AuditSoftware.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
View AuditServers.ps1
#----------------------------------------------------------------------##
# 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
You can’t perform that action at this time.