Skip to content

Instantly share code, notes, and snippets.

View Stephanevg's full-sized avatar
:shipit:
I like computers

Stéphane Stephanevg

:shipit:
I like computers
View GitHub Profile
@Stephanevg
Stephanevg / powershell_classes_pratical_example_Part3.ps1
Created September 1, 2016 20:43
Contains powershell class example with enum, constructor overloads, logic using enum types, and static method.
Enum ServerType {
HyperV
Sharepoint
Exchange
Lync
Web
ConfigMgr
}
Class Computer {
@Stephanevg
Stephanevg / powershell_classes_pratical_example_Part2.ps1
Created September 1, 2016 20:45
Contains powershell class example with enum, constructor overloads, logic using enum types.
Enum ServerType {
HyperV
Sharepoint
Exchange
Lync
Web
ConfigMgr
}
Class Computer {
@Stephanevg
Stephanevg / class_computerconfiguration.ps1
Last active September 4, 2016 08:56
Regroups all the necessary elements for the creation of server and client devices in active directory.
{
"Owner":"",
"Type":"",
"Description":"Web Server",
"ServiceOwner":"Marketing"
}
Class ComputerConfiguration {
[string]$Owner
@Stephanevg
Stephanevg / Replace-NetIpAddress.ps1
Created September 22, 2016 17:13
Replaces a network ip address / gateway (instead of adding a new one)
Function Replace-NetIpAddress{
[cmdletbinding()]
Param(
[int]$interfaceIndex,
[IPaddress]$NewIp,
[int]$Prefix,
[IPaddress]$Gateway
)
$IpParams = @{}
@Stephanevg
Stephanevg / Get-NetshFireWallRule
Created December 22, 2016 19:12
Get the current firewall rules. This function is a wrapper around NETSH. It has been written to address the lack of cmdlet on Windows 2008R2 and previous versions. It should be used ONLY for systems prior to 2012.
Function Get-NetshFireWallrule {
Param(
[String]$RuleName
)
if ($RuleName){
$Rules = netsh advfirewall firewall show rule name="$ruleName"
}else{
$Rules = netsh advfirewall firewall show rule name="all"
}
@Stephanevg
Stephanevg / Read-WindowsUpdateLog.ps1
Last active January 17, 2017 17:07
Reads the WindowsUpdate.log file and creates a Powershell object with it's content.
Function Read-WindowsUpdateLog {
Param (
[Parameter(MAndatory=$false)]
[ValidateScript({
test-Path $_
})]
[string]$Path = (Join-Path -path $Env:windir -ChildPath WindowsUpdate.log),
[PArameter(Mandatory=$false)][datetime]$Date,
@Stephanevg
Stephanevg / htmlskeleton.html
Created January 22, 2017 21:42
html skeleton
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<title></title>
<link href="style.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
@Stephanevg
Stephanevg / Get-NetshWindowsFireWallProfile.ps1
Created January 23, 2017 15:08
Uses NETSH to return the existing Windows firewall profiles. It returns all the elements in reworkable powershell objects (instead of plain text).
Function Get-WindowsFireWallProfile {
<#
.Synopsis
Get the windows firewall profile
.DESCRIPTION
Get the windows firewall profile based on netsh commands. Returns a workable powershell object.
This function has been speceically developed to by pass the case where
.EXAMPLE
Get-WindowsFireWallProfile
Returns all the existing profiles
@Stephanevg
Stephanevg / CloneExample.ps1
Last active April 20, 2017 13:18
Make clone an existing PowerShell class using IClonable Interface
class Car {
[String] $Make
[String] $Model
[Object]Clone(){
return $this.MemberwiseClone()
}
[void]Display(){
Write-host "The car model is: $($this.Model) and make: $($this.Make)"
@Stephanevg
Stephanevg / ConvertDocumentTo-Markdown.ps1
Created May 9, 2017 12:09
Converts a PsScribo Document to Markdown
Function ConvertDocumentTo-Markdown {
[CmdletBinding()]
Param(
[Parameter(Mandatory, ValueFromPipeline)]
[System.Object] $Document,
$Path = 'C:\Temp\export.md'
)
Function ConvertTableTo-Markdown {
<#