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"
View set.ps1
New-VMSwitch -Name "TeamedvSwitch" -AllowManagementOS $true -NetAdapterName "Ethernet","Ethernet 3" -EnableEmbeddedTeaming $true
View ps_Errors.ps1
function Reset-Errors {
$Global:Error.Clear()
$psISE.Options.ErrorForegroundColor = '#FFFF0000'
$Global:ErrorView = 'NormalView'
}
Reset-Errors
#generate an error
function Show-Error {
Get-Item c:\doesnotexist.txt
View Splat.ps1
$paramHash = @{
ServiceName = "BITS"
ComputerName = "Localhost"
Outvariable = "results"
}
Get-Service @paramHash