Skip to content

Instantly share code, notes, and snippets.


Loïc MICHEL kayasax

View GitHub Profile
kayasax / callURL.ps1
Created May 21, 2015
équivalent de invoke-webrequest pour powershell V2.
View callURL.ps1
$string="http://server/app/index.php?var=val1&var2={0}" -f $event.providerName
(New-Object System.Net.WebClient).DownloadString("$string");
kayasax / sccm.ps1
Last active Aug 29, 2015
powershell SCCM automation
View sccm.ps1
$UIResource = New-Object -ComObject UIResource.UIResourceMgr
#list available software
$UIResource.GetAvailableApplications() | select ID,PackageID,PackageName
#install a soft
$UIResource.ExecuteProgram('*','CT1005EE',$true) # ID, PackageID, execute after download
View stringformat.ps1
-f Format operator
Format a string expression.
"String with placeholders" -f "Array of values to place into the placeholders"
'Filename: {0} Created: {1}' -f $_.fullname,$_.creationtime
"{I,A:FS} {I,A:FS} {I,A:FS}.." -f "string0", "string1", "string2"...
kayasax / calculatedProperty.ps1
Created Sep 9, 2015
Calculated property syntax
View calculatedProperty.ps1
Get-ChildItem C:\Test | Select-Object Name, CreationTime, @{Name="Kbytes";Expression={$_.Length / 1Kb}}
kayasax / isVM.ps1
Last active Sep 15, 2015
Determine if powershell runs within a virtual machine.
View isVM.ps1
function isVM{
(gwmi win32_bios).version -match "vrtual"
or (from
Function isVM {
$objWMI = Get-WmiObject Win32_BaseBoard
View decrypt_securestring.ps1
$p=read-host "password ?" -assecurestring
$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($p)
$clearpassword = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr)
see more here
kayasax / Powershell Script Template.ps1
Last active Dec 22, 2015
Template for powershell script. Makes all errors "terminating" and send mail if error occurs
View Powershell Script Template.ps1
# Templata.ps1
# author: Loic MICHEL
# date: 10/09/2013
# abstract: make all errors terminating errors and send email + raise event in case of failure
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")
$folder =$sch.GetFolder("\subfolder")
#import .xml
Get-childItem -path $task_path -Filter *.xml | %{
kayasax / updateWMIProperty.ps1
Created Jan 7, 2016
modify wmi property. Key is to use [wmiobject].put() method source
View updateWMIProperty.ps1
$p=gwmi sms_packagebaseclass -Namespace root\sms\site_CT1 |?{$_.packageId -eq "CT1006FA"}
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)