>NULL: July 2019

Thursday 25 July 2019

powerShell 365

Connect to Office 365 PowerShell
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session


Connect to Azure PowerShell
$LiveCred = Get-Credential
Connect-MsolService -Credential $LiveCred

Import-Module Azure


Set the calendar permissions of another user: 
set-MailboxFolderPermission -Identity alias:\calendar -User user@example.com -AccessRights Owner


Set the Default user on every mailbox calendar to Reviewer
$users = Get-Mailbox | Select -ExpandProperty Alias
Foreach ($user in $users)
{
Write-Host $user
set-MailboxFolderPermission $user":\Calendar" -user default -accessrights reviewer
get-MailboxFolderPermission $user":\Calendar" -user default
write-host ""
}

Find where a mailbox alias is in use
Get-Mailbox -Identity * | Where-Object {$_.EmailAddresses -like 'smtp:alias@example.com'} | Format-List Identity

Get details of all folders in all mailboxes
Get-Mailbox | Select-Object alias                                            `
| foreach-object {                                                           `
    Get-MailboxFolderStatistics -Identity $_.alias                           `
    | select-object Identity, ItemsInFolder, FolderSize, FolderAndSubfolderSize }

Remove forwarding on a mailbox
Set-Mailbox bob -ForwardingAddress $Null
Set-Mailbox bob -DeliverToMailboxAndForward $False

Recover all recently deleted items from retention
Restore-RecoverableItems -Identity alias




Create a CSV of AD users and their managers

Run the following in PowerShell changing the path at the end to suit your needs, the output can then be sorted by the Manager column in Excel.

get-aduser -Filter * -Properties Manager | Select-Object Name,sAMAccountName,Manager | export-csv C:\Scripts\UsersWithManagers.csv -notypeinformation

Monday 22 July 2019

Using forfiles to remove older backups (last resort) 14 days and older.

Add the following as a second step in the SQL job, possible catches are you need to set the first step behavior as run second step on success. Modify Advanced Page for success action. Second step Type: Operating System (CmdExec).

F:
CD F:\SQLBackups
forfiles /m *.bak /c "cmd /c Del @file" /d -14


Friday 19 July 2019

HP Chromebook 11-1101 Resurrection, Orange Light, will not power on

So my trusty old HP Chromebook 11-1101 (the slim cheap blue and white Chromebook pictured below) turned it's self off due to low battery last night. Fair enough, I put it on charge, this morning the charging light was still orange, I disconnected the charger and flipped the power off at the wall then back on reconnected the charger but noticed the orange light was still on, without the charger connected.

Oh, and it wouldn't power on either!

So here's the fix. Hold the Power  and Refresh  keys down simultaneously for 5 seconds. Your Chromebook will turn off the orange charging light and boot up all being well.

I thought my favourite laptop of all time had gone to laptop heaven, but it seems CPR exists for Chromebooks.



Image result for hp chromebook 11-1101