Office 365 – List members of Shared Mailboxes

List members of Shared Mailboxes (Microsoft 365)

1. Connect to Office 365 PowerShell, run the PowerShell ISE as Administrator and execute the following command:

Set-ExecutionPolicy RemoteSigned
$Cred = Get-Credential

2. Type your user ID and password in the Windows PowerShell Credential Request and click OK.

3. Create a session using the following command, modifying –ConnectionUri parameter based on your Exchange Online location:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Cred -Authentication Basic –AllowRedirection

4. Connect to Exchange Online:

Import-PSSession $Session –DisableNameChecking

5. Copy and run the following script, adjusting the filters for the specific user you want to report on and specifying the desired path for the CSV file output:

Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Get-MailboxPermission |Select-Object Identity,User,AccessRights | Where-Object {($_.user -like ‘*@*’)}|Export-Csv C:\Temp\sharedfolders.csv  -NoTypeInformation 

6. Review the resulting CSV report:

7. Terminate your session with following cmdlet:

Remove-PSSession$Session

PHP self:: vs $this

For people unfamiliar with Object Oriented Programming (OOP), using classes / objects can be a bit of an endeavor your first time through. However, OOP can be extremely powerful in making your code dynamic and helping to minimize your efforts when developing. It’s also an excellent method for sort of lumping your code into categories that make sense.

One of the most common mistakes I see, is that people use $this when they should really be using self::. To understand when we should use each, lets create an example.

So lets say that in some PHP script, I want to be able to create some “vehicle” objects. I do this because, I want an easy way to keep track of how many tires each vehicle has, what color paint it has, and I want a function that builds me an array of cars. So my class might look something like this:

<?php
class Vehicle {
    public $numberOfTires = 0;
    public $paintColor = null;

    public function __construct($tires, $color)
    {
        $this->numberOfTires = $tires;
        $this->paintColor = $color;
    }

    public function paint($color)
    {
        $this->paintColor = $color;
    }

    public static function buildCars($amount)
    {
        $cars = array();
        for($i = 0; $i < $amount; $i++)
        {
            $color = self::getRandomVehicleColor();
            $cars[] = new Vehicle(4, $color);
        }

        return $cars;
    }

    public static function getRandomVehicleColor()
    {
        $colors = array('black', 'blue', 'red');
        return $colors[mt_rand(0, count($colors)-1)];
    }
}

So now let’s break down what all of that actually does. First we have our __constructor function. This is a kind of magic PHP function that is in every class. Even if you don’t define it, it is there, just empty. This is what gets called when you use new Vehicle(4, 'black');. Notice, that inside of the constructor we are setting those public variables, defined at the top of the class typically. This is essentially creating our vehicle object. So that way in our main script we can do things like this:

<?php
$myCar = new Vehicle(4, 'black');
$myBicycle = new Vehicle(2, 'red');

echo $myBicycle->numberOfTires; //echo's the number 2
echo $myCar->paintColor; //echo's the string 'black'

So you noticed that when i used $this inside of the class, I was referring to that specific instance of the object, in this case vehicle. For added re-enforcement I created the paint() function so that I can show you how you can leverage this even further. Say you created your object of $myCar, but now you want to repaint your car. That’s easy enough to do by creating a function (albeit a very simple one) and then calling that function on the object you want it to apply to. Like this:

<?php
$myCar = new Vehicle(4, 'black');
echo $myCar->paintColor; //echo's the string 'black'
$myCar->paint('blue');
echo $myCar->paintColor; //echo's the string 'blue' now

So we’ve covered that $this is used in order to apply functions to the instance of the object. But now we want a function to create us a bunch of instances. This is something that I would still classify as being related to the object, so it makes good sense for me to create a function inside of that class to do that for me. In this case, we want to create us a bunch of cars, which are vehicles with 4 tires. We’ll do this by calling a static function we built in our class.

<?php
$cars = Vehicle::buildCars(25); //return an array of 25 vehicle objects;

So, now to talk about self:: You’ll notice that inside of our buildCars() function we use self:: to call the getRandomVehicleColor() function. Notice that this is also a static function, in other words, I don’t actually have to have a vehicle instance, to pick a random vehicle color. These are the instances when you use self and not $this. Bottom line, $this is referencing the current instance of the object and is applied to non-static functions, self:: is for static functions that are not dependent on having an instance of the object to use or if you want to call a function from the creating class.

Office 365 – Room Lists

Create Room List Distribution Groups

New-DistributionGroup -Name “Name of Room List” –RoomList creates a new Room List Distribution Group using the cmdlet’s minimum required parameters for a Room List Distribution Group. If you don’t specify any additional parameters, then they will be set for you.

You may want to take control of your recipient object’s attributes by using additional parameters, e.g. –Alias, –DisplayName, –PrimarySmtpAddress, etc. You can find a full list of available parameters at TechNet New-DistributionGroup: Exchange 2010 SP1 Help.

New-DistributionGroup -Name Bldg_HUB -DisplayName “Student Union Building Conf Rooms” –PrimarySmtpAddress Bldg_HUB@contoso.edu –RoomList

Add existing Room Mailboxes to Room List Distribution Groups

Add-DistributionGroupMember –Identity “Name of Room List” –Member “Name of Room Mailbox“adds Room Mailboxes to Room List Distribution Groups. It requires that you specify the Room List Distribution Group using the –Identity parameter and the Room Mailbox to be added using the –Member parameter.

Add-DistributionGroupMember –Identity Bldg_HUB -Member Room_HUB1001 
Add-DistributionGroupMember –Identity Bldg_HUB -Member Room_HUB1002

You can use the DisplayName, Identity, PrimarySmtpAddress and various other values with the –Identity and –Memberparameters. You might find it helpful to list them.

The following command will list the Room List Distribution Groups.

Get-DistributionGroup | Where {$_.RecipientTypeDetails -eq “RoomList”} | Format-Table DisplayName,Identity,PrimarySmtpAddress

The following command will list the existing Room Mailboxes.

Get-Mailbox | Where-Object {$_.RecipientTypeDetails -eq “RoomMailbox”} | Format-Table DisplayName,Identity,PrimarySmtpAddress
Script to check if something else is running.

This is a simple script to check that something else is still running and if not start it up again.

[bash]

#!/bin/sh
SERVICE=’mqtt3′

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$SERVICE service running, everything is fine"
else
echo "$SERVICE is not running"
# echo "$SERVICE is not running!" | mail -s "$SERVICE down" root
nohup /usr/bin/python3 /home/pi/bin/mqtt3.py &

fi

 

[/bash]

crontab

@reboot crontab directive only actually fires if its applied against the root account.

It makes some sort of sense, however no real technical reason that I can see.

BT Price Increase

It appears that BT are about to up the price of their broadband again. Price increase is due to arrive in January.

So as soon as I get the price increase letter I will be cancelling completely.  Now all I have to do is find a mobile phone sim only deal. Perhaps Virgin is the way to go.

Update Late November. It appears that BT don’t know the rules and have sent me a bill for cancelling all my services. Will be having an interesting conversation on the subject soon.

 

So update on the 26th of January, received a final notice for payment of my termination fees. So finally got around to calling their billing department and explaining. After 20 minutes on the phone they are sending me a cheque for £11.00.

Beeping WD PIDrive 314GB

Turn off

After my system boot:

[dinux@alarmpi ~]$ sudo hdparm -B /dev/sda1
/dev/sda1:
APM_level = 128

Then i set -B value to 255

sudo hdparm -B 255 /dev/sda1

Check again:

[dinux@alarmpi ~]$ sudo hdparm -B /dev/sda1
/dev/sda1:
 APM_level	= off
Christmas Fun

He’s making a list

And checking it twice

Gonna find out who’s naughty & nice Santa Claus is…

in breach of the Data Protection Act (1998)

National Grid Battery

So we know the issue, green energy is not consistent or might not be available when its actually needed so we need some really massive batteries on the national grid so we don’t have to turn on or up the dirty power stations.

So far we have hydro, so when the demand on the grid is less then the generation capacity we can pump water up into upper elevation reservoirs and when the power is required it drops to the lower reservoirs to generate hydro electricity.

Now we have a new battery, is called cryogenic storage. Its uses excess generation capacity to chill air and when the power is required the warming air expands and drives the turbines.

See

http://www.bbc.co.uk/news/science-environment-37902773

We need more of this sort of thing.