Sunday, March 26, 2023

System-preferred multifactor authentication (MFA)

 Microsoft Azure Active Directory has Introduced new security control to securing MFA, called as System-preferred MFA. During user's MFA it will default prompt most secured MFA method user has registered.

For an example: If user has registered SMS and authenticator as a method for MFA system preferred MFA evaluated and prompt for authenticator app. User can still sign-in by other sign-in method.

Below are the points to consider.

  •  By default this feature is disabled.
  •  System always determines and presents the most secure method user has registered.
  •  It can be enabled only for a single group, which can be a dynamic or nested group.
How to enable this feature?
    • Graph API : 





    • Azure AD Portal:  Go to Security blade ->Authentication method ->Settings ->  









Friday, January 29, 2021

PowerShell Script to repair WMI

 Below PowerShell Script help to Fix the WMI issue.

    Stop-Service Winmgmt -Force -ErrorAction SilentlyContinue

Start-Sleep -Seconds 20


    $status = $null

    Do 

    {

        $status = (Get-Service -Name Winmgmt).Status

    }

    While ($status -notlike "*Stopped*")


Rename-Item -Path C:\Windows\System32\wbem\repository -NewName 'Repository.old1' -Force -ErrorAction SilentlyContinue


Start-Sleep -Seconds 20


Start-Service -Name Winmgmt



Friday, August 28, 2020

How to Create an array with user input in PowerShell


$arr =@() #Create a variable for array
Write-Host "how many numbers you  want in An Array" 
[int]$LenOfArray = Read-Host  #User Input
for ($i=0;$i -lt $LenOfArray$i++)
{
  $num = Read-Host "Enter $i Index number";
 $arr +=$num
}
Write-Host "The Array is $arr"

Friday, June 5, 2020

Want to hide output in PowerShell ?

Out-Null 

When we execute any command in cmdlet, usually it send its result down the pipe line .
In other words, we can say if we execute any command it display it's output.
Let's see below, here it is listing all the child item inside the windows directory.

 
Now we will use out-null, let's go : Here it does not return any output.

Thursday, May 21, 2020

Using FilterHashTable In powerShell

A hashtable is Similer an array,But it use "key = value” type of syntax.
Let's See how to use FilterHashTable for a filter.

Here is I am trying to get the System event with the specific event ID 1017.
I passed a parameter "Maxevents", will list the only one event .


Get-WinEvent -FilterHashtable @{LogName = 'System'; ID = 1014} -MaxEvents 1|ft -Wrap






Sunday, May 10, 2020

Splatting in PowerShell


Splatting is a method of passing a group  of parameter to a command as unit.
PowerShell associates each value in the collection with a command parameter.
Splatted parameter values are stored in named splatting variables, which look like standard variables, but begin with an At symbol (@) instead of a dollar sign ($).

 The At symbol tells PowerShell that you are passing a collection of values, instead of a single value.
 It Improves the  readability Code.

Here is the way :

$parm = @{
    name = "testuser"
    AccountExpires = "11-05-2020"
    Description ="This is test user,will be deleted soon"
    password = Read-Host "Enter the passoword" -AsSecureString

}
New-LocalUser @parm



Friday, May 8, 2020

PowerShell Passthru Parameter




There are many Windows PowerShell cmdelts that simply work, and they do not return any data.
Here with the Passthru parameter, PowerShell returns the output in the console.

Here I simply use "Start-Process notepad", It started notepad process but did not return the Output
to the console.

PS D:\VS Codes\C\myproject1> Start-Process notepad       
PS D:\VS Codes\C\myproject1>


Now I will use "PassThru" Parameter, Let's See .

PS D:\VS Codes\C\myproject1> Start-Process notepad -PassThru

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
      1       2      520        196       0.16  23436   1 notepad

Here It started the the Process Notepad, and gave me the output of the execution of command .

Note: You want to know how many Windows PowerShell cmdlets have "passthru" patameter

Get-Command -CommandType 8 | where {$_.definition -match ‘passthru’}

Featured post

System-preferred multifactor authentication (MFA)

Popular Posts