Activeren 2FA in Azure AD via Powershell

 Indien je met de basis variant van Azure AD werkt heb je niet de mogelijkheid om een aparte beleidsregel aan te maken waarin je kunt aangeven dat gebruikers 2FA vereisen. Hiervoor moeten alle gebruikers handmatig aangepast worden via een (onhandige) interface. Gelukkig kunnen de aanpassingen ook via PowerShell op groepen gebruikers uitgevoerd worden.

Connect naar de Azure tenant

Connect-MsolService

Bekijk hoe de authenticatie methoden nu ingesteld staan

Get-MsolUser -all | Where-Object {$_.StrongAuthenticationMethods -like "*"}  | select UserPrincipalName,StrongAuthenticationMethods,StrongAuthenticationRequirements

Inschakelen van 2FA

Om 2FA in te schakelen moet eerst de “StrongAuthenticationRequirement” ingeschakeld worden.

$mf= New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement
$mf.RelyingParty = "*"
$mfa = @($mf)

Schakel 2FA voor een enkele gebruiker in

Set-MsolUser -UserPrincipalName "username" -StrongAuthenticationRequirements $mfa

Schakel 2FA voor alle gebruikers in

Get-MsolUser -All | Set-MsolUser -StrongAuthenticationRequirements $mfa

Schakel 2FA voor een enkele gebruiker uit

$mfa = @()
Set-MsolUser -UserPrincipalName eshlomo@elishlomo.us -StrongAuthenticationRequirements $mfa 

Delen via: Facebooktwitterpinterestlinkedinmail

Basic Powershell commands

On this page some simple but useful Powershell commands are shown. These commands are the basics of the usage of Powershell.

To search all Powershell cmdlets for a keyword the ‘Get-Command’ command can be used. The ‘Get-Command’ can be abbreviated to ‘gcm’. To search for all commands that contain the word ‘network’ you can use the following commands.

gcm

Get-Command

It is also possible to serach within a specific module. To search in the NetTCPIP module the following command can be used:

Module

If you need to know more about a specific cmdlets you can use the ‘Get-Help’ command followed by the command you want to have more information about.

Get-Help

If you want to know the details of an cmdlet the ‘Get-Member’ command can be used. If you for example want to know what information can be shown with the ‘Get-Process’ command the following command can be used:

Get-Member

Within an output you can search for a specific value. To search for specific values you can use the ‘Where-Oject’ command. In this example we search for all processes named MMC.

Where-Object

The first thing the code is doing is getting a list of processes on our computer and passing the output (using the | character) to our Where-Object cmdlet. The cmdlet takes a script block as a parameter. The script block instructs the Where-Object cmdlets to only select objects where their name parameter is equal to ‘mmc’. The result is a list of the MMC instances that are running.

To stop all the instances of MMC that are running you can pipe the output to a ‘Stop-Process’ command.

Stop-ProcessDelen via: Facebooktwitterpinterestlinkedinmail

VMware PowerCLI script to add storage and VLAN’s

When deploying multiple VMware hosts you can use the Template feature in vSphere. If you’re not licenced to use the template feature in vSphere you can use the VMware PowerCLI PowerShell commands to quickly add the strorage and the networks.

First thing you got to do is connect to the host:

  • Connect-VIServer -Server esx.jvr.local

To add VLAN’s to a vSwitch use the following command:

  • get-vmhost -name esx.jvr.local | Get-VirtualSwitch -name vSwitch0 | new-VirtualPortGroup -name “LAN” -vlanid 0
  • get-vmhost -name esx.jvr.local | Get-VirtualSwitch -name vSwitch0 | new-VirtualPortGroup -name “PVS” -vlanid 2310

To add NFS storage use the following commands:

  • get-vmhost -name esx.jvr.local | New-Datastore -Nfs -Name ESX1 -Path /NAS_ESX1 -NfsHost 10.10.10.50

This can also be done at the cluster level. The following command’s can be used:

  • Get-Cluster “CLUSTER_1” | Get-VMHost | Get-VirtualSwitch -name vSwitch1 | New-VirtualPortGroup -name “PVS” -VLanId 2310
  • Get-Cluster “CLUSTER_1” | Get-VMHost | Get-VirtualSwitch -name vSwitch1 | New-VirtualPortGroup -name “HB” -VLanId 2309

Delen via: Facebooktwitterpinterestlinkedinmail

Basic App-V 5 Client PowerShell Commands

These PowerShell commands should be run on an App-V 5 Client computer. The first step is importing the App-V module, as it’s not imported by default.

  • Import-Module AppvClient

This must be run to import the module to allow PowerShell to run PowerShell cmdlets for the App-V 5 Client.

  • Get-Command -Module Appvclient

This gets a list of PowerShell commands for the App-V Client module.

  • Add-AppvPublishingServer -Name [Name of App-V Publishing Server] -URL [URL]

Adds the specified App-V 5 Publishing Server to the App-V 5 Client.

  • Sync-AppvPublishingServer -Name [Name of App-V Publishing Server]

Syncs the App-V 5 Client’s apps with the App-V 5 Publishing Server.

  • Add-AppvClientPackage \\Servername\Sharename\Appfilename.appv

Adds a package to the local App-V 5 Client.

  • Add-AppvClientPackage \\Servername\Sharename\Appfilename.appv | Publish-AppvClientPackage -Global

Delen via: Facebooktwitterpinterestlinkedinmail