View writehost.ps1
write-host “This is something that will display in the console.” |
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" |
View CorrectDefaultParam.ps1
function DefaultValue([int]$valueParam = 10){ | |
Write-Host $valueParam | |
} | |
DefaultValue |
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 |
NewerOlder