View dateFormat.ps1
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
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
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
var params={};window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(str,key,value){params[key] = value;}); |
View WMINamespace.ps1
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
gwmi -namespace "root" -class "__Namespace" | Select Name | |
Be careful: There are TWO underscores in front of Namespace! |
View environment_var.ps1
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
[Environment]::SetEnvironmentVariable("UPFRODCNAME", "RODC-VALAN", "machine") |
View ADSI_group_membership.ps1
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) | |
} |
View updateWMIProperty.ps1
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() | |
View decrypt_securestring.ps1
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 |
View registry.ps1
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
# 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\\CurrentVersion",$true) | |
then regkey.setvalue("Name","Myvalue") | |
# to access a registry path without a psdrive (hklm: etc.) use the registry provider : | |
cd registry::\HKEY_USERS |
View isVM.ps1
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 |
View calculatedProperty.ps1
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}} |
NewerOlder