This file contains hidden or 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-ADGroup "Group Name" | Get-ADGroupMember -Recursive | Get-ADUser -Properties * | Select SamAccountName,GivenName,sn,Mail |
This file contains hidden or 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
| #search latest files | |
| $dir = "C:\Users\Admin\Documents" | |
| $latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1 | |
| #we specify the directory where all files that we want to upload | |
| $Dir="C:/Users/Admin/Documents/"+ $latest.name | |
| #ftp server | |
| $ftp = "ftp://ftp.someaddress.com/dir/" | |
| $user = "login" |
This file contains hidden or 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
| #Check if the account exists. | |
| If($Results.Count -eq 0) | |
| { | |
| Write-Warning "The SamAccountName '$UserName' cannot find. Please make sure that it exists." | |
| } | |
| Else | |
| { | |
| Foreach($Result in $Results) | |
| { | |
| $DistinguishedName = $Result.Properties.Item("DistinguishedName") |
This file contains hidden or 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
| Set-StrictMode -Version Latest | |
| $payload = @{ | |
| "channel" = "#my-channel" | |
| "icon_emoji" = ":bomb:" | |
| "text" = "This is my message. Hello there!" | |
| "username" = "Mr. Robot" | |
| } | |
| Invoke-WebRequest ` |
This file contains hidden or 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
| #requires -Version 3.0 | |
| #Assume sql server SMO is installed, https://msdn.microsoft.com/en-us/library/ms162189(v=sql.110).aspx | |
| add-type -AssemblyName "Microsoft.SQLServer.Smo, Version=11.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91"; | |
| add-type -AssemblyName "Microsoft.SQLServer.SmoExtended, Version=11.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91"; | |
| [boolean] $debug =$true; # $true = print out the t-sql; $false = execute the restore | |
| [string] $bkup_folder = 'c:\Backup\*' #the folder where the backup files are located. Can be a network share | |
| [string] $sql_instance = 'TP_W520'; #this is the destination sql instance where the restore will occur. Change it to your own. |
This file contains hidden or 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
| $command = 'send-mailmessage -from -to -subject "$env:computername has been restarted" -body "The server $env:computername has recently restarted. If this was unexpected please log into the server and check the cause as soon as possible." -smtpserver ' | |
| $bytes = [system.text.encoding]::Unicode.GetBytes($command) | |
| $encodedCommand = [convert]::tobase64string($bytes) | |
| echo $encodedCommand > encodedtext.txt | |
| notepad encodedtext.txt |
This file contains hidden or 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
| # Define the Computer Name | |
| $computerName = "dc1" | |
| # Define the IPv4 Addressing | |
| $IPv4Address = "10.10.100.25" | |
| $IPv4Prefix = "24" | |
| $IPv4GW = "10.10.100.1" | |
| $IPv4DNS = "8.8.8.8" | |
| # Get the Network Adapter's Prefix |
This file contains hidden or 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
| $domainName = "contoso.com" | |
| $netBIOSname = "CONTOSO" | |
| $mode = "Win2012R2" | |
| Install-WindowsFeature AD-Domain-Services -IncludeAllSubFeature -IncludeManagementTools | |
| Import-Module ADDSDeployment | |
| $forestProperties = @{ |
This file contains hidden or 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
| # Define DNS and Sites & Services Settings | |
| $IPv4netID = "10.10.100.0/24" | |
| $siteName = "LAB" | |
| $location = "New Lab City" | |
| # Define Authoritative Internet Time Servers | |
| $timePeerList = "0.us.pool.ntp.org 1.us.pool.ntp.org" | |
| # Add DNS Reverse Lookup Zones | |
| Add-DNSServerPrimaryZone -NetworkID $IPv4netID -ReplicationScope 'Forest' -DynamicUpdate 'Secure' |
This file contains hidden or 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
| $baseDN = "DC=contoso,DC=com" | |
| $resourcesDN = "OU=Resources," + $baseDN | |
| New-ADOrganizationalUnit "Resources" -path $baseDN | |
| New-ADOrganizationalUnit "Admin Users" -path $resourcesDN | |
| New-ADOrganizationalUnit "Groups Security" -path $resourcesDN | |
| New-ADOrganizationalUnit "Service Accounts" -path $resourcesDN | |
| New-ADOrganizationalUnit "Workstations" -path $resourcesDN | |
| New-ADOrganizationalUnit "Servers" -path $resourcesDN | |
| New-ADOrganizationalUnit "Users" -path $resourcesDN |