Search This Blog

Tuesday, May 26, 2020

Chrome: Setup for cloud tools and multiple web accounts

 I make no claim that this is the base way to achieve this, but it helped me organise and allowed me to use chrome accross the board.

 My Issue: I look after multiple accounts within AWs, Google and Azure/Office365... When using these cloudtools, if you have multiple user accounts within these environments it can become a pain to ensure you are logged in as the correct user, or in some cases it will jump between accounts...

I was looking for a way to allow me to have difference chrome instances, that were meant for different user accounts..

Enter --user-data-dir

(caveat here, is I know that there are profiles within chrome, but I not entirely sure these are fully isolated from one another.. Using --user-data-dir, I believe gets me around these issues.)

So --user-data-dir, allows you to point chrome at a completely isolated set of user folders.. You use it by running chrome as follows.. And the good thing is, the first time you run it, it will create the folder for you.. I created a folder to contain all of my different user-data folders C:\ChromeUserDataFolders, then when I run the command I put the account name\email that I will be using that folder instance for.

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="C:\ChromeUserDataFolders\mygoogleaccount@gmail.com"

I also like to run my web tools as apps within chrome, and once the above is setup you can start installing the URLs as apps (or shortcuts as chrome calls them). You can then run these using the shortcuts created,

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=":\ChromeUserDataFolders\mygoogleaccount@gmail.com" --app-id=plfjfmlifxvdfgerglcklncmcfice

So here is a screen shot of me writing this blog post, in my chrome running as an shortcut (hence missing menus etc at the top), but running from a dedicated folder for this specific google user account.
   Google Blogger - as chrome shortcut (app)

Share/Bookmark

Wednesday, May 20, 2020

automated - timestamped ping and tracert with logs (powershell)

Recently I had to run ping tests to provide to my internet provider... TPG.... I have an issue where in the evening my latency spikes (goes from around 7-10ms to up over 200ms, which makes gaming a joke and non event) from around 19:00 to 22:00... This has never happened before, so is abnormal..

In the past I have had no real issue with the support, however this time it has been slow... and a real waste of time... I had already turned off wifi and disconnected all devices except my test machine.. The issue still existed... the increased latency was appearing on the first hop to the TPG gateway from my router.. and only in the evening.. by 22:30 the issue was going away.
They wanted me to run various traceroutes, but the main one to TPG.COM.AU, to show that the latency appeared within the tpg network... which it clearly did as it was the first hop... my gateway..

Multiple times I provided them the same information, and then it took some convincing to get access to an engineer... although I am still waiting on that call... over a week later...

So.. I then decided I wanted to automate this to run a constant ping and regular tracerts.. which were timestamped...

I already have a page that detailed how to created a timestamped ping... so I used this as the basis o a couple of scripts I would schedule.

The ping would run hourly, running a ping for 59 minutes... (3540 successfull pings (1 ping a second)) (there are issues with this and it occurs with timeouts...as they are 4 seconds..).. However this will be better than not having it at all, and potentially something I could fix.

The tracert would run every 5 minutes, with dnslookup enabled to ensure the host details were recorded..

Scripts are below but logging and stdout look like the following, the logs will be created in the same folder as the script and with a timestamped name. ping

2020-05-20 20:36:01 :  2020-05-20T20:36:01.9175593+10:00: 
2020-05-20 20:36:01 :  2020-05-20T20:36:01.9378688+10:00: Pinging tpg.com.au [203.26.27.38] with 32 bytes of data:
2020-05-20 20:36:02 :  2020-05-20T20:36:02.0514975+10:00: Reply from 203.26.27.38: bytes=32 time=134ms TTL=125
2020-05-20 20:36:03 :  2020-05-20T20:36:03.0439801+10:00: Reply from 203.26.27.38: bytes=32 time=125ms TTL=125
tracert

2020-05-20 22:03:01 :  2020-05-20T22:03:01.8844980+10:00: 
2020-05-20 22:03:01 :  2020-05-20T22:03:01.9053306+10:00: Tracing route to tpg.com.au [203.26.27.38]
2020-05-20 22:03:01 :  2020-05-20T22:03:01.9083060+10:00: over a maximum of 30 hops:
2020-05-20 22:03:01 :  2020-05-20T22:03:01.9112846+10:00: 
2020-05-20 22:03:06 :  2020-05-20T22:03:06.4692141+10:00:   1    <1 1.1.1.1="" 1="" 2-2-2-2-static.tpgi.com.au="" 2020-05-20="" 2020-05-20t22:03:12.1730325="" 2020-05-20t22:03:13.2970152="" 2020-05-20t22:03:14.4112638="" 2020-05-20t22:03:15.6023222="" 2020-05-20t22:03:16.7043576="" 2020-05-20t22:03:17.8930681="" 2020-05-20t22:03:17.8970367="" 2020-05-20t22:03:17.9005089="" 22:03:12="" 22:03:13="" 22:03:14="" 22:03:15="" 22:03:16="" 22:03:17="" 2="" 3-3-3-3-s.tpgi.com.au="" 37="" 3="" 4-4-4-4-s.static.tpgi.com.au="" 41="" 43="" 4="" 5-5-5-5-s.tpgi.com.au="" 53="" 54="" 55="" 56="" 57="" 58="" 59="" 5="" 60="" 6="" 77="" 78="" 79="" 7="" 80="" 85="" 86="" :="" code="" complete.="" gateway="" ms="" router="" trace="" www.tpg.com.au="">
And here are both scripts...

ping (pingTPGwithTimestamp.ps1)

3 input parameters
  • $pingDestination (default tpg.com.au) 
  • $pingAmount (default 4) 
  • $Logging (switch) 

Here is the command I run
".\pingTPGwithTimestamp.ps1" -logging -pingDestination "tpg.com.au" -pingAmount 3540

How to configure Taskscheduler to run the powershell script
Program\Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 
Add arguments: -ExecutionPolicy Bypass -WindowStyle Minimized -File ".\pingTPGwithTimestamp.ps1" -logging -pingDestination "tpg.com.au" -pingAmount 3540 
Start in: C:\Powershell\~Home\TPG (do not put quotes around this it will fail to run)



[CmdletBinding()]
param( 
        [Parameter(Mandatory=$false)] [AllowEmptyString()] [string] $pingDestination ='tpg.com.au',
        [Parameter(Mandatory=$false)] [AllowEmptyString()] [int16] $pingAmount = 4,
        [switch] $Logging
    )

$FormatENumerationLimit=-1;

function timestamp ($log)
{
    Process {
            $resultPing = "$(Get-Date -Format o): $_";
            write-host $resultPing;
            if ($Log)
            {
                LogWrite $resultPing;
            }
    }
}


function Get-ScriptDirectory
{
 #Determine the folder in which the script lives.
 $Invocation = (Get-Variable MyInvocation -Scope 1).Value
 Split-Path $Invocation.MyCommand.Path
}

#needed to find the location of the script.
$scriptPath = Get-ScriptDirectory;
$scriptName = $MyInvocation.MyCommand.Name;

$LogfileTimeStampName = (Get-Date).toString("yyyyMMddHHmmss");
$Logfile = "$scriptPath\$($scriptName)_$LogfileTimeStampName.log";

Function LogWrite
{
   Param ([string]$logstring);
   $LogStamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss");
   Add-content $Logfile -value "$LogStamp :  $logstring";
}

PING.EXE $pingDestination -n $pingAmount | timestamp($logging.IsPresent)

tracert(tracertTPGwithTimestamp.ps1)

2 input parameters
  • $dnslookup (switch) 
  • $Logging (switch) 
Here is the command I run
".\tracertTPGwithTimestamp.ps1" -logging  -dnslookup

How to configure Taskscheduler to run the powershell script
Program\Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 
Add arguments: -ExecutionPolicy Bypass -windowstyle Minimized -File ".\tracertTPGwithTimestamp.ps1" -logging  -dnslookup
Start in: C:\Powershell\~Home\TPG (do not put quotes around this it will fail to run)




[CmdletBinding()]
param( 
        [Parameter(Mandatory=$false)] [AllowEmptyString()] [string] $tracertDestination ='tpg.com.au',
        [switch] $dnslookup,
        [switch] $Logging
    )

$FormatENumerationLimit=-1;

function timestamp ($log)
{
    Process {
            $resulttracert = "$(Get-Date -Format o): $_";
            write-host $resulttracert;
            if ($Log)
            {
                LogWrite $resulttracert;
            }
    }
}


function Get-ScriptDirectory
{
 #Determine the folder in which the script lives.
 $Invocation = (Get-Variable MyInvocation -Scope 1).Value
 Split-Path $Invocation.MyCommand.Path
}

#needed to find the location of the script.
$scriptPath = Get-ScriptDirectory;
$scriptName = $MyInvocation.MyCommand.Name;

$LogfileTimeStampName = (Get-Date).toString("yyyyMMddHHmmss");
$Logfile = "$scriptPath\$($scriptName)_$LogfileTimeStampName.log";

Function LogWrite
{
   Param ([string]$logstring);
   $LogStamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss");
   Add-content $Logfile -value "$LogStamp :  $logstring";
}

if ($dnslookup)
{
    tracert.exe $tracertDestination | timestamp($logging.IsPresent)
}
else {
    tracert.exe -d $tracertDestination | timestamp($logging.IsPresent)
}


Share/Bookmark

Wednesday, October 16, 2019

Office 365–Hybrid / Migration Issues

Had to look into issues of an existing Office 365 Hybrid environment.
The environment had been setup for some time… They had initially made a test migration for some users.. but this had then been rolled back due to various issues (including free\busy).
Below I am going to document the problem areas and what I did to resolve. Hopefully this will help some people. Mileage may vary depending on your setup..
Background: Hybrid environment, with most users still on prem except for a few remote users.

Free\Busy

This was not working between on-prem and cloud users… Various articles were consulted, and everything was in place, but it was just not working. Stumbled across someone who said that re-running the Hybrid Config Wizard fixed their issues..
Note: It is recommended that the rerunning of the Hybrid Config Wizard is done after any config change to the current config.. new connectors/domains..
Notes: At the time of writing getting hold of the Hybrid Config Wizard still requires you to use Internet Explorer… Other browsers just don’t work.
Running the hybrid wizard you will need a local on-prem domain admin account and a office365 account that is an admin.
Re-running the wizard for us, not changing anything, fixed our issues.
Related Articles
Send As / Send on behalf of / Full Access

Full Access

This should just work if set in the Office 365 gui

Send On-behalf of

On-Premise User to Send on behalf of Cloud user
  • On local Exchange Server
  • Set-RemoteMailbox <cloud user> –GrantSendonBehalfTo <on-prem user>
  • On Exchange Online (Office 365)
  • Set-MailUser <cloud user> –GrantSendOnBehalfTo <on-prem user> 

Send As

On-Premise User to Send As Cloud user
  • On local Exchange Server
  • Get-remotemailbox -Identity <cloud user> | Add-ADPermission -User <on-prem user> -ExtendedRights Send-As
  • On Exchange Online (Office 365)
  • $UserCredential = Get-Credential
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  • Import-PSSession $Session -DisableNameChecking
  • Get-mailbox -Identity <cloud user> | Add-RecipientPermission -Trustee <on-prem user> -AccessRights SendAs
Cloud user to send as On-Premise User
  • On local Exchange Server
  • Get-mailbox -Identity <on-prem user> | Add-ADPermission -User <cloud user> -ExtendedRights Send-As
  • On Exchange Online (Office 365)
  • $UserCredential = Get-Credential
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  • Import-PSSession $Session –DisableNameChecking
  • Add-RecipientPermission -Identity <on-prem user> -Trustee <cloud user> -AccessRights SendAs
Related Articles

Voting Buttons / Out of Office
On local Exchange Server
  • Set-RemoteDomain "contoso.mail.onmicrosoft.com" -TNEFEnabled $true -AllowedOOFType "InternalLegacy"
On Exchange Online (Office 365)
  • Run the following PowerShell command in Exchange Online, wait 30 minutes, and then test again.
  • Set-RemoteDomain "default" -TNEFEnabled $true -AllowedOOFType "InternalLegacy"
Related Articles
Calendar Delegation (Access)
 
Set-OrganizationConfig -ACLableSyncedObjectEnabled $True
for previously moved mailboxes... single (for testing)..
Get-AdUser <cloud user1 AD account> | Set-AdObject -Replace @{msExchRecipientDisplayType=-1073741818}
Get-AdUser <cloud user2 AD account> | Set-AdObject -Replace @{msExchRecipientDisplayType=-1073741818}
for previously moved mailboxes... multiple users.. (this was run, after testing single accounts above).
Get-RemoteMailbox | ForEach { Get-AdUser -Identity $_.Guid | Set-ADObject -Replace @{msExchRecipientDisplayType=-1073741818}}
Verify
Get-RemoteMailbox | ForEach { Get-AdUser -Identity $_.Guid -Properties msExchRecipientDisplayType | Format-Table -AutoSize msExchRecipientDisplayType,DistinguishedName}
Prior to this update all remote mailboxes were set to -2147483642
msExchRecipientDisplayType DistinguishedName
-------------------------- -----------------
-2147483642 CN=xxxx,OU=xxx,OU=Users,OU=xxxxx,OU=xxxxx,DC=xxxxx

Related Articles
Public Folders….
No issues with these but there are many different directions to take with… So I put down my generic thoughts… No Rhyme or reason….
Get-PublicFolderStatistics | Sort-object itemcount -desc | FT
Get-PublicFolderStatistics | Sort-object -property itemcount -desc | FT
Get-PublicFolder -recurse | Select-object -property name,identity | Sort-object -property Identity

Get-PublicFolder -recurse | Select-Object -property name,identity,foldersize | Sort-object -property foldersize -desc | FT -autosize

List all objects in public folders with dates
Get-PublicFolder -Recurse | Get-PublicFolderItemStatistics | Select-Object -property PublicFold
erName,CreationTime,LastModificationTime,Subject | Export-Csv -path C:\Temp\publicfolderdetails.csv -NoTypeInformation
Public Folders in Office365 cannot be Contacts or Tasks.
Use Shared Mailboxes, not using Office 365 groups as we cannot assign security groups, and would have to enter all members manually!!!! Apparently this is coming....
Shared Mailbox, has limit of 50GB before licence needed.
Tested exporting contacts from a public folder into a shared mailbox.
Shared Mailboxes….
Online Shared Mailbox has to be created in On-Premise and then migrated over to Office365. If the Shared Mailbox is created directly in Office365, it can send email externally but not receive external email.

Share/Bookmark

Tuesday, November 13, 2018

Run TimeStamped Pings against large Computer list

Had to run long term ping test against a number of devices. As such I created the following script that will ping the devices, with a timestamp, logging to a file.

computer list is in a file, should be in the same folder as the script. In this case file called ips.txt.

param ([ Int32 ] $ PingCount = 14400 , [ string ] $ file = '.\ips.txt' )

 

function Get-ScriptDirectory

{

    #Determine the folder in which the script lives.

    $ Invocation = ( Get-Variable MyInvocation -Scope 1 ).Value

    Split-Path $ Invocation .MyCommand.Path

}

 

$ scriptPath = Get-ScriptDirectory

 

$ TimeStampPing = {

    param ( $ comp , $ count , $ scriptPathBlock )

    filter timestamp { " $ ( Get-Date - Format o): $ _ " } ;

    ping $ comp -n $ count | timestamp > " $ ( $ scriptPathBlock )\pingtest- $ ( $ comp ).txt"

  }

 

foreach ( $ line in Get-Content $ file ) {

    Start-Job -ScriptBlock $ TimeStampPing -ArgumentList $ line , $ PingCount , $ scriptPath

}


Share/Bookmark