Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

October 2, 2018

AWS VPC IPsec Connection Configuration

Client Side Network
Remote computers:
Endpoint1: These IP address: 192.168.20.0/24 (client network)
Endpoint2: These IP address: 192.168.10.0/24 (AWS network)
Requirements: require inbound and clear outbound
Method Advanced: First auth: Preshared Key
Advanced:
Profile: domain, private, public
Interface type: all interface
IPsec tunneling: User IPsec tunneling, 
endpoint 1: 192.168.20.11 (host IP)
endpoint 2: AWS provided remote tunnel endpoint

AWS Side Network:
Customer Gateway Address: cline Public IP
Category VPN
Routing Static
Static Routes: 192.168.20.0/24


! Script for Tunnel 1:
netsh advfirewall consec add rule Name="Tunnel 1" ^
Enable=Yes Profile=any Type=Static Mode=Tunnel ^
LocalTunnelEndpoint=192.168.20.11 ^
RemoteTunnelEndpoint=[AWS Provided] Endpoint1=192.168.20.0/24 ^
Endpoint2=192.168.10.0/24 Protocol=Any Action=RequireInClearOut ^
Auth1=ComputerPSK Auth1PSK=[AWS Provided] ^
QMSecMethods=ESP:SHA1-AES128+60min+100000kb ^
ExemptIPsecProtectedConnections=No ApplyAuthz=No QMPFS=dhgroup2

Make sure the Firewall is on and it will initiate the IPsec VPN. Check VPC\routing table make sure it appoint to new virtual gate way if you renew the VPN connection. Switching IPsec tunnel connection, security group, if something should work but not working


Ref:
http://www.blog.labouardy.com/vpn-connection-aws-resources-raspberry-pi-3/
https://forums.aws.amazon.com/thread.jspa?threadID=116589

September 27, 2018

Exchange Related Powershell

Get GUID for email and find the path by searching GUID

Find path by using email:
search ***@company.com or ***@company.onmicrosoft.com if find the object, the SMTP has been used.
Get-MailPublicFolder "***@company.onmicrosoft.com" | FL *Guid*

We can use the GUID to location the path in public folder
Get-PublicFolder -Recurse -resultsize unlimited | ?{$_.MailRecipientGuid -eq "***-****-****-****-*****"}

| select -ExpandProperty folderpath
Using regex to identify number in Powershell
$myvar -match "^\d+$" #pure number
$myvar -match ".*\d+.*" #*number*

Find the public folder path by searching email (Not work for Exchange Online O365)



Login Office 365 Powershell

$LiveUsername='***@***.com' $LivePassword='' $LiveCred = New-Object System.Management.Automation.PsCredential($LiveUsername, (ConvertTo-SecureString $LivePassword -AsPlainText -Force)) Import-Module MSOnline Connect-MsolService -Credential $LiveCred $msoExchangeURL = “https://ps.outlook.com/powershell/” $session =New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $msoExchangeURL -Credential $Livecred -Authentication Basic -AllowRedirection Import-PSSession $session

Updated 2020/10
$LiveUsername='***@***.com' $LivePassword='' $LiveCred = New-Object System.Management.Automation.PsCredential($LiveUsername,(ConvertTo-SecureString $LivePassword -AsPlainText -Force)) #$Cred = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking