This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$string="http://server/app/index.php?var=val1&var2={0}" -f $event.providerName | |
(New-Object System.Net.WebClient).DownloadString("$string"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-f Format operator | |
Format a string expression. | |
Syntax: | |
"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"... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem C:\Test | Select-Object Name, CreationTime, @{Name="Kbytes";Expression={$_.Length / 1Kb}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isVM{ | |
(gwmi win32_bios).version -match "vrtual" | |
} | |
or (from http://www.windowsnetworking.com/kbase/WindowsTips/Windows7/AdminTips/VirtualPlatforms/UsingPowerShelltodeterminewhetherWindowsisrunninginavirtualmachine.html) | |
Function isVM { | |
$objWMI = Get-WmiObject Win32_BaseBoard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$p=read-host "password ?" -assecurestring | |
$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($p) | |
$clearpassword = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr) | |
[System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr) | |
see more here | |
http://stackoverflow.com/questions/7468389/powershell-decode-system-security-securestring-to-readable-password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Templata.ps1 | |
# author: Loic MICHEL | |
# date: 10/09/2013 | |
# abstract: make all errors terminating errors and send email + raise event in case of failure | |
# | |
[CmdletBinding()]param( | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | %{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$p=gwmi sms_packagebaseclass -Namespace root\sms\site_CT1 |?{$_.packageId -eq "CT1006FA"} | |
$p.Priority=2 | |
$p.put() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
([ADSI]"WinNT://$ip/$admingroup,group").psbase.Invoke("Members") |%{ | |
$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null) | |
} |