Skip to content

Instantly share code, notes, and snippets.

Loïc MICHEL kayasax

  • Colas
  • France
Block or report user

Report or block kayasax

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
View get-hotfix2.ps1
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")))}}
}
@kayasax
kayasax / parameters.ps1
Last active Jun 14, 2017
Exemple d'usage de PARAMETER
View parameters.ps1
[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"
View registry.ps1
# 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 / dateFormat.ps1
Last active Nov 10, 2016
Date format (to be used with -format parameter of get-date)
View dateFormat.ps1
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
View getURLParameters.js
var params={};window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(str,key,value){params[key] = value;});
@kayasax
kayasax / WMINamespace.ps1
Created Aug 17, 2016
listing WMI namespace
View WMINamespace.ps1
gwmi -namespace "root" -class "__Namespace" | Select Name
Be careful: There are TWO underscores in front of Namespace!
View environment_var.ps1
[Environment]::SetEnvironmentVariable("UPFRODCNAME", "RODC-VALAN", "machine")
@kayasax
kayasax / ADSI_group_membership.ps1
Created Feb 2, 2016
Get group membership with ADSI
View ADSI_group_membership.ps1
([ADSI]"WinNT://$ip/$admingroup,group").psbase.Invoke("Members") |%{
$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)
}
@kayasax
kayasax / updateWMIProperty.ps1
Created Jan 7, 2016
modify wmi property. Key is to use [wmiobject].put() method source https://technet.microsoft.com/en-us/library/ee692805.aspx
View updateWMIProperty.ps1
$p=gwmi sms_packagebaseclass -Namespace root\sms\site_CT1 |?{$_.packageId -eq "CT1006FA"}
$p.Priority=2
$p.put()
@kayasax
kayasax / SchedulerService.ps1
Created Sep 20, 2013
Import & export of scheduled tasks using scheduler service
View SchedulerService.ps1
# create task from its xml definition
$sch = New-Object -ComObject("Schedule.Service")
$sch.connect("computername")
$root=$sch.GetFolder("\")
$root.CreateFolder("subfolder")
$folder =$sch.GetFolder("\subfolder")
#import .xml
Get-childItem -path $task_path -Filter *.xml | %{
You can’t perform that action at this time.