View publicIP.ps1
$ip = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
$ipinfo.ip
$ipinfo.hostname
$ipinfo.city
$ipinfo.region
$ipinfo.country
$ipinfo.loc
$ipinfo.org
View installCheck.ps1
$scomInstallCheck = Get-WmiObject -Class Win32_Product -ErrorAction Stop | `
? { $_.Name -eq "Microsoft Monitoring Agent" }
View ps_runas.ps1
function Get-ImpersonatetLib {
if ($script:ImpersonateLib) {
return $script:ImpersonateLib
}
$sig = @'
[DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
[DllImport("kernel32.dll")]
View moduleSource.ps1
cd (Get-Module PSDesiredStateConfiguration -ListAvailable).ModuleBase
psEdit .\PSDesiredStateConfiguration.psm1
#now lets search the source code for what we are looking for and get line numbers
Select-String -Path .\PSDesiredStateConfiguration.psm1 -Pattern EncryptedToPlaintextNotAllowed
View secureCred.ps1
$PASSWORD = 'password'
$user = "domain\user"
$secureString = ConvertTo-SecureString -AsPlainText -Force -String $PASSWORD
$credential = New-Object `
-TypeName System.Management.Automation.PSCredential `
-ArgumentList $user,$secureString
View netAdapterBindings.ps1
<#
disable/enable network binding
DisplayName ComponentID
----------- -----------
File and Printer Sharing for Microsoft Networks ms_server
Client for Microsoft Networks ms_msclient
Internet Protocol Version 4 (TCP/IPv4) ms_tcpip
Microsoft Network Adapter Multiplexor Protocol ms_implat
Internet Protocol Version 6 (TCP/IPv6) ms_tcpip6
Link-Layer Topology Discovery Responder ms_rspndr
View windowsUpdateVersion.ps1
(Get-ItemProperty -Path 'C:\Windows\System32\wuaueng.dll').VersionInfo | ft -autosize
View MoveFilesToNewDirectory.ps1
$origPath = 'C:\Users\username\Desktop\images\files'
$destPath = 'C:\destfolder\foldertest'
Get-ChildItem -Path $origPath -Recurse -File | Move-Item -Destination $destPath
Remove-Item $origPath
View TrustCerts.ps1
##############################################################
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
View base_config.ps1
$compname = "20161"
$ip = "10.0.2.4"
#find a way to get the interfaceindex
$index = Get-NetAdapter | Select-Object -ExpandProperty ifIndex
#now set the ip of that index adapter
New-NetIPAddress -InterfaceIndex $index -IPAddress $ip -PrefixLength 16 -DefaultGateway 10.0.0.1
#now set the DNS for that index adapter
Set-DnsClientServerAddress -InterfaceIndex $index -ServerAddresses 10.0.3.190
$cred = Get-Credential -UserName domain\user -Message "Enter domain creds"