Skip to content

Instantly share code, notes, and snippets.

View kayasax's full-sized avatar

Loïc MICHEL kayasax

  • Microsoft
  • France
View GitHub Profile
[Environment]::SetEnvironmentVariable("UPFRODCNAME", "RODC-VALAN", "machine")
@kayasax
kayasax / WMINamespace.ps1
Created August 17, 2016 06:14
listing WMI namespace
gwmi -namespace "root" -class "__Namespace" | Select Name
Be careful: There are TWO underscores in front of Namespace!
@kayasax
kayasax / getURLParameters.js
Created August 26, 2016 08:20
get URL parameters
var params={};window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(str,key,value){params[key] = value;});
@kayasax
kayasax / dateFormat.ps1
Last active November 10, 2016 15:00
Date format (to be used with -format parameter of get-date)
for filename use : (Get-Date -Format yyy-MM-dd-HHmm)
Specifier;Format;Sample Output
d;ShortDatePattern;8/30/2007
D;LongDatePattern;Thursday, August 30, 2007
f;Full date and time (long date and short time);Thursday, August 30, 20
F;FullDateTimePattern (long date and long time);Thursday, August 30, 2007 11:19:59 AM
g;General (short date and short time);8/30/2007 11:20 AM
G;General (short date and long time);8/30/2007 11:20:24 AM
m, M;MonthDayPattern;August 30
@kayasax
kayasax / registry.ps1
Last active December 19, 2016 13:10
Working in the registry with powershell. Link : https://technet.microsoft.com/fr-fr/library/dd315394.aspx
# for remote access use this
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer1)
$RegKey= $Reg.OpenSubKey("SOFTWARE\\Veritas\\NetBackup\\CurrentVersion")
$NetbackupVersion1 = $RegKey.GetValue("PackageVersion")
#If you want to set a value, use
$RegKey= $Reg.OpenSubKey("SOFTWARE\\Veritas\\NetBackup\\CurrentVersio‌​n",$true)
then regkey.setvalue("Name","Myvalue")
# to access a registry path without a psdrive (hklm: etc.) use the registry provider :
cd registry::\HKEY_USERS
@kayasax
kayasax / parameters.ps1
Last active June 14, 2017 11:23
Exemple d'usage de PARAMETER
[CmdletBinding()] #make script react as cmdlet (-verbose etc..)
param(
[Parameter(Position=0, Mandatory=$true,ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[System.String]
$service,
[Parameter(Position=1)]
[System.string]
$computername="local"
function get-hotfix2{
param($computername)
#$PSBOundParameters
Get-HotFix @PSBOundParameters |
Select-Object description,hotfixid,installedby, @{l="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
}