Batch Process an Array via Powershell for FIMService write back (Or any PS scenario)

So,

A long time ago I wrote a post showing how you can do Composite write-back to FIMService via Powershell. That used “Search-ResourcePaged” command from the Lithnet Module. But it’s not helpful in the scenario where you already have a list of users (say an exported CSV or a text file) you want to perform some action on. In that scenario, XPath is not needed (and might not help if there is no pattern to search) as you already have your objects to work on.

So say, for example, I have a list of 10000 objectID from FIM and want to delete them.

Simple way will be

Pretty simple but will take about 1/sec and take 10000 seconds to do it.

Yeah I am not going to wait that long…

Did some RnD (and Google) and found some different ways of going about it..

One way was doing ForEach -Parallels flag. I tried it but actually had a reverse affect for me… I did it wrong obviously.. It worked but took long/er for some reason (Even with -throttlelimit set)… Moved on… Went above my head for the limited time I had to do the job.

Then found a pretty simple way to do it online and made some modification to suit my scenario

 

Voila!!! it’s done in seconds. It will send batch of 1000 objects at a time to FIMService as a composite request and do them quickly. I did like 10000 in 10-15 seconds or so. You can also import a csv/txt file and create an array as well.

I am not a powershell expert and it may not be perfect or most elegant way of doing it but gets the job done quickly.

You can use the logic for virtually anything and not just to write back to FIMService. But yeah helped me to do large modifications / deletes pretty quickly.

Till the next time…

Passwords: Evil Necessity to be Protected!!!

I had missed posting this on the World Password Day but forgot to hit publish (my bad 😛 )

You know your passport – Your very physical identity which you put in a locker or in a safe place. Or while you are travelling you keep it with you at all times and don’t leave it someone insecure.

Well, your digital identity is the same (I think more important tbh in this day and age). You post your life on Facebook, rant on twitter, upload ur food likes on Instagram and wierd faces on snapchat, music preference on Apple Music or Spotify, look for a job in Linkedin and so much more.

In our ever-growing presence of our online footprint, we mostly use a password to login to each service we consume. In some instance, you might use OpenID to log in to a new service using an existing account on facebook/google/LinkedIn etc. Depending on your circumstances you might choose either – a new standalone account to the service or an OpenID connection to that service.

If you go password, I see people tend to use a known password in their brain (easy to repeat) for multiple services. They might even add a number like 123 to “make different passwords” for the same composition – BAD IDEA!!!

We are humans after all and it’s in our nature to do repetitive tasks easily and thus passwords are no different. If you use the same password and any of those services are hacked or compromised, the hacker has probably your username/email and your password which he will definitely try to exploit and use on various other services. They’ve hit a jackpot.

To remove the human element in the password creation and remembering, I would say use a Password Manager. There are many online/ offline/hybrid password managers out there.

I really don’t know any password of the services I use expect the Master Password of my Password Manager and my main/recovery email account – you know just in case I need to login to recover the master password or other sites.

I would basically try to list some practices I have used for years and ways of securing yourself online

  1. Register yourself and your family to sites like https://haveibeenpwned.com/: Sites like these notify you if your email address has been found in any PUBLIC data breaches. Of course, many breaches are not made public so you don’t know what you don’t know.
  2. Get yourself a password manager and randomize all your services password. Rule of thumb – You SHOULD NOT remember the password for most of the services you use. If you do, it’s probably easy(ier) to crack. Some good password managers I have used are
    • LastPass: It has some nice features like Security Score which audits the security level of your passwords and tells you which ones to harden and which services have been compromised. You should run that and try to score high. It also has a feature to auto change password for many popular services like facebook/twitter etc where it itself logs in and performs a password change so you don’t have to do the steps or remember the new passwords. There are plugins for all major browsers which it can autofill to log in to the service. LastPass free is good enough for individual accounts and don’t really need paid service. But for a family account, you might want to and it’s not expensive.
    • 1Password: Mac lovers love this. Among features mentioned on top it also has Watchtower which notifies you of breaches and tells you to same password (LastPass has similar feature) and Travel Mode which allows you to remove your password vault from your computer if you are travelling into a country where you think you might not want them to have access to your passwords on a forced check on entry. It’s costly subscription model but it’s much better looking and sleek to say.
    • There are others like DashLane and BitWarden which I haven’t used but highly regarded in the community
  3. Now the Master Password to your Password Manager – Obvious to say, DON’T USE AN EASY ONE. But you need to remember this password obviously. One way of doing it is Diceware logic. Basically using that logic you throw a dice 5 times to generate a number which then corresponds to a letter in a list. Then you can do this 5-6 times to generate a long list of random words. This helps you to remember the word. And then further you can replace characters with symbols or special characters. How this helps is that now you have rolled the dice 5 times for a word x 6 times for 6 words = 6 x 5 letter words = 30 characters and then further replace few characters with its resembling special character or symbol or capitalize (like 1 for l, $ for s and so on). This will help you generate a secure 30 character password which is easy to remember (like d0ggyl1f3$d1c3dt00myc@d3T) – I can remember that. Don’t try it.. not my password 😛
  4. ENABLE MFA on your password manager – If it doesn’t have it.. DON’T BUY IT.

In the end, I would like to say that you and your family and your colleagues and anyone who is even a bit concerned about their online security and presence, should implement strong password regime. Use a secure password manager, randomize all passwords such that you don’t remember them and that they are unique to each service, use some logic of your own or Diceware such that your master password is super lengthy and secure and of course enable MFA on your password managers as well.

Some of the practices I have used for sometime… What do you think? Be strong!!! Be safe!!!

Powershell Tip: FIM/MIM Explicit Disconnectors be gone… quickly!!!

Happy New Year!!! Hope everyone had a great 2017 and hopefully an even better 2018

If you know disconnectors then you definitely know how irritating the FIM/MIM GUI can be to convert a disconnector from explicit to normal or vice versa when you have potentially 10’s or 100’s of them… Joiner tab isn’t really friendly to select multiple disconnectors and “batch” convert them.

Thanks to Lithnet MIIS Powershell you can do the conversion of 100’s of them in 1 line and in couple of seconds

If you have a MA with 100’s of explicit disconnectors just run the following command (replacing the <MA NAME> with the ….. MA Name )

Done… Simples… You can ofcourse do the opposite as well if you wish i.e. Normal disconnectors -> Explicit Disconnectors.

Powershell Tip: Send quick Email when a service goes down [Update: And bring it back up]

Yes we have SCOM monitoring and stuff, but if some testing or debugging is going on and do don’t want to do down the hassle of setting up alerts and just simply want to get notified when a service goes down, here is a simple script

 

It’s pretty self explanatory.

You can also send it to multiple recipients

 

Voila!! It will check every 10 seconds and if the service is in any other state apart from “Running”, it will send you an email and stop execution.

Update: And easy to bring it back up when it goes down. Run the following in PS as Admin. It will send a mail when service is down and bring it back up.

 

 

AzureAD: Get List of all users with a particular license

You might have to do reporting and want a list of all users in Azure AD which have a particular license..

Following is an easy way to do so

Get-MsolAccountSku will give you a table of all the License Types you have and count

AccountSkuId ActiveUnits WarningUnits ConsumedUnits
TENANTNAME:AAD_BASIC 300000 0 1
TENANTNAME:AAD_PREMIUM 300000 0 200000
TENANTNAME:AAD_PREMIUM_P2 300000 0 200000
TENANTNAME:POWER_BI_STANDARD 1000000 0 200000

You can then choose the AccountSkuId you want to report on and pass that in the “TENANTNAME:AAD_PREMIUM” of the Get-MSOLUser command

It took me about 20 min to run this report for about 155000 users