Reworking the Script
Throw out everything you know about scripts while disregarding any fears or anxieties you have around the command-line. Scripting can be easy, fun, and make your life 10x easier the more you use it. Before writing a script you should think of a key objective or goal that you would like to accomplish. Going into writing a script, you should have a clear understanding of what you would like to be able to achieve, then you can go into writing the draft.
PowerShell executable script files are saved and written with the ps1 file extension. You can then execute these scripts via PowerShell by running the following command in the prompt:
Luckily if you’re just starting with JumpCloud and PowerShell, we have a full GitHub Wiki with all of the commands that you can use to manage your JumpCloud organization. If you leverage these pre-written commands in tandem with your tenant, you could easily compile a script to perform a specific action.
Imagine you are looking to list all Users without MFA enabled on their accounts, enable MFA on your Users, as well as enabling MFA on a System Group’s systems that do not have it enabled already. This can be done through the UI with several clicks through a few different menus, or could be easily compiled within a script where you can perform both tasks with a singular call.
For example, contents of a script to achieve this could be:
#Get all Users with MFA disabled on their JumpCloud User Account and enable it#
Get-JCUser -enable_user_portal_multifactor $false | Set-JCUser -enable_user_portal_multifactor $True
#Get all Systems within the All Systems Group with MFA disabled and enable it#
Get-JCSystemGroupMember -GroupName “All Systems" | Set-JCSystem -allowMultiFactorAuthentication $true
*** This is a Security Bloggers Network syndicated blog from Blog – JumpCloud authored by Daniel Fay. Read the original post at: https://live-jc-marketing-site.pantheonsite.io/blog/powershell-automation