# Import the AzureAD module Import-Module AzureAD # Connect to Azure AD Write-Host "Connecting to Azure AD..." Connect-AzureAD # Define the path to the CSV file $csvPath = "C:\HRM users License Report\cleanup\DisabledAccont12Nov2024.csv" # Import the CSV file Write-Host "Importing user list from CSV..." $users = Import-Csv -Path $csvPath # Loop through each user in the CSV file and delete the account Write-Host "Starting user deletion process..." foreach ($user in $users) { $userPrincipalName = $user.UserPrincipalName # Adjust the column name if needed try { # Retrieve the user by UserPrincipalName using the filter approach $azureADUser = Get-AzureADUser -Filter "UserPrincipalName eq '$userPrincipalName'" if ($azureADUser) { # Delete the user using ObjectId Write-Host "Attempting to delete user: $userPrincipalName" Remove-AzureADUser -ObjectId $azureADUser.ObjectId Write-Host "Deleted user: $userPrincipalName" -ForegroundColor Green } else { Write-Host "User not found: $userPrincipalName" -ForegroundColor Yellow } } catch { Write-Host "Failed to delete user: $userPrincipalName. Error: $_" -ForegroundColor Red } } Write-Host "User deletion process completed."
Friday, November 15, 2024
Delete AzureAD user
Friday, January 26, 2024
Azure AD users Sign in logs for 30 days report
#PowerShell script reads the All guest account details as a CSV and check in Azure AD sign in logs 30 days and generates the report file # Install the AzureAD module (if not already installed) Install-Module -Name AzureAD -Force -AllowClobber # Import the AzureAD module Import-Module AzureAD # Connect to Azure AD (you will be prompted for credentials) Connect-AzureAD # Read CSV file $csvPath = "C:\Report\AllGuestUsers.CSV" $csvData = Import-Csv -Path $csvPath # Array to store results $results = @() # Iterate through each row in the CSV foreach ($row in $csvData) { $email = $row.email Write-Host $email -ForegroundColor Green # Get sign-in logs for the specific email $signInLogs = Get-AzureADAuditSignInLogs -Filter "startsWith(userPrincipalName, '$email')" # Check if any sign-in logs were found $status = if ($signInLogs.Count -gt 0) { 'Found' } else { 'Not Found' } # Create an object with the email and status $result = [PSCustomObject]@{ Email = $email Status = $status } # Add the result to the array $results += $result } # Export results to CSV $results | Export-Csv -Path "C:\Report\Results.csv" -NoTypeInformation # Display a confirmation message Write-Output "Results exported to Results.csv"
Disable guest account from Azure AD reading CSV file
#This PowerShell script is used to read a CSV file having list of User Principal name (not email) #and disable the account in azure AD # Install the AzureAD PowerShell module if not already installed Install-Module -Name AzureAD -Force -AllowClobber -Scope CurrentUser # Import the AzureAD module Import-Module AzureAD # Connect to Azure AD Connect-AzureAD # -Credential $credential # Specify the path to your CSV file $csvFilePath = "C:\Report\Final\UserPrinicpalList.csv" # Read the CSV file $csvData = Import-Csv -Path $csvFilePath # Iterate through each row in the CSV foreach ($row in $csvData) { $upn = $row.UserPrincipalName # Get the user object from Azure AD $azureADUser = Get-AzureADUser -Filter "UserPrincipalName eq '$upn'" if ($azureADUser) { Write-Host $email -ForegroundColor Green # Disable the user account Set-AzureADUser -ObjectId $azureADUser.ObjectId -UserPrincipalName $upn -AccountEnabled $false Write-Host "Azure AD account for $email has been disabled." } else { Write-Host $upn -ForegroundColor Red Write-Host "User with email $upn not found in Azure AD." } }
Thursday, December 21, 2023
Connect SharePoint site with Azure AD app registration client id and secret
#Script is used to test that sharepoint site gets connected with Azure AD app registration client id and secret. $abc=Connect-PnPOnline -Url "https://miracl.sharepoint.com/sites/testsite-2" -ClientId "920cf67c-2973-423a-b419-" -ClientSecret "Rol8Q~WyNV_fA0IdCXWfyl5hhq2V5LA5_PMBLakt" Get-PnPWeb New-PnPList -Title "Contoso AD App List" -Template GenericList
Azure AD APP API Sites.Selected - 2
#Get-InstalledModule -Name "PnP.PowerShell" #Uninstall-Module -Name PnP.PowerShell #Install-Module -Name PnP.PowerShell -RequiredVersion 1.12.0 #Get-Command -Module PnP.Powershell #Update-Module -Name "PnP.PowerShell" #Script reads a csv file name "file.csv" having threee columns SiteURL,AppID and AppDisplayName
#Script grant Azure AD App having API sites.selected to access SharePoint site with "FullControl" permission.try { $csvData = Import-Csv -Path "file.csv" # Get the current date and time $timestamp = Get-Date -Format "yyyyMMdd-HHmmss" foreach ($row in $csvData) { $siteURL = $row.SiteURL $appID = $row.AppID $appDisplayName = $row.AppDisplayName $displayNameConcatenated = "$appID - $appDisplayName" Connect-PnPOnline -Url $siteURL -Interactive # Grant Write permissions to the Azure AD app on the site Grant-PnPAzureADAppSitePermission -AppId $appID -DisplayName $displayNameConcatenated -Site $siteURL -Permissions Write # Fetch Permission ID $PermissionId = Get-PnPAzureADAppSitePermission -AppIdentity $appID # Set permissions to FullControl using the fetched permission ID Set-PnPAzureADAppSitePermission -Site $siteURL -PermissionId $($PermissionId.Id) -Permissions "FullControl" # Construct the filename with a timestamp $filename = "Success-AzureADAppSitePermissions_$timestamp.txt" # Retrieve Azure AD app permissions for the site and store the output in a file $permissionOutput = Get-PnPAzureADAppSitePermission -Site $siteURL $permissionOutput | Out-File -FilePath $filename -Encoding UTF8 -Force # Completion message in green Write-Host "Script executed successfully!" -ForegroundColor Green } } catch { # Display error message in red Write-Host "An error occurred: $($_.Exception.Message)" -ForegroundColor Red # Log error to a separate file $errorLogFilename = "ErrorLog_$timestamp.txt" $_.Exception.Message | Out-File -FilePath $errorLogFilename -Encoding UTF8 -Force }
Thursday, February 9, 2023
Azure AD APP API Sites.Selected
This is always an issue to control SharePoint sites permission access. If this is for the user or the Application.
User permission can be controlled by SharePoint permission list but Application permission can not be controlled directly and that is possible from the Application configuration through graph API .
1) Select sites.selected from API for requested App
2) Run PS script to allow respective app to connect with specific SharePoint site with provided roles only
Install-Module -Name PnP.PowerShell -RequiredVersion 1.12.0
Install-Module PnP.PowerShellc Get-Command -Module PnP.Powershell
#Connect with PnP online # NO WEBLOGIN This will work with Get-Credential ONLY having Global Admin rights Connect-PnPOnline -Url "https://miracl.sharepoint.com/sites/testsite-1/" -Credential (Get-Credential) #Get All Lists Get-PnPList 1) Approach-1
Grant-PnPAzureADAppSitePermission -AppId 'e5b3606c-341c-492f-8b65-e109c94be' -DisplayName 'TESTSP' -Site 'https://miracl.sharepoint.com/sites/testsite-1' -Permissions Write Grant-PnPAzureADAppSitePermission -AppId 'e5b3606c-341c-492f-8b65-e109c94be' -DisplayName 'TESTSP' -Site 'https://miracl.sharepoint.com/sites/testsite-1' -Permissions Read
here -DisplayName can be any name , just to recognize the configured appbelow command will confirm the applied changes.Get-PnPAzureADAppSitePermission -Site https://miracl.sharepoint.com/sites/testsite-1
2) Approach-2
Need to execute two commandlets. First grant Read or Write permissions. Then update it to Manage or FullControl
https://www.blimped.nl/running-application-with-limited-sharepoint-permissions/https://www.leonarmston.com/2022/01/pnp-powershell-csom-now-works-with-sharepoint-sites-selected-permission-using-azure-ad-app/$PermissionId = Get-PnPAzureADAppSitePermission -AppIdentity e5b3606c-341c-492f-8b65-e109c94be # $PermissionId will return ID, Roles and Apps name and ID
Set-PnPAzureADAppSitePermission -Site https://miracl.sharepoint.com/sites/testsite-1 -PermissionId $(($PermissionId).Id) -Permissions "FullControl" Set-PnPAzureADAppSitePermission -Site https://miracl.sharepoint.com/sites/testsite-1 -PermissionId $(($PermissionId).Id) -Permissions "Read" Set-PnPAzureADAppSitePermission -Site https://miracl.sharepoint.com/sites/testsite-1 -PermissionId $(($PermissionId).Id) -Permissions "Write" Set-PnPAzureADAppSitePermission -Site https://miracl.sharepoint.com/sites/testsite-1 -PermissionId $(($PermissionId).Id) -Permissions "Manage"
Revoke the Access
Connect-PnPOnline -Url $siteURL -Interactive
$PermissionId = Get-PnPAzureADAppSitePermission -AppIdentity $appID
Revoke-PnPAzureADAppSitePermission -PermissionId $PermissionId.Id -Force
Test with Client ID and Secret
$abc=Connect-PnPOnline -Url "https://miracl.sharepoint.com/sites/testsite-2" -ClientId "920cf67c-2973-423a-b419-" -ClientSecret "Rol8Q~WyNV_fA0IdCXWfyl5hhq2V5LA5_PMBLakt"
Get-PnPWeb
New-PnPList -Title "Contoso AD App List" -Template GenericList
###################Complete Script is mentioned in another blog###################
Tuesday, August 30, 2022
Copy page from one sharepoint site to other sharepoint site
$group_list = Import-Csv 'C:\WW\SiteList.csv'
$srcUrl = "https://shared.sharepoint.com/sites/fj-mech-dev/"
$pageName = "Home-Team.aspx"
#$cred = Get-Credential
Connect-PnPOnline -Url $srcUrl -Credentials $cred
#$Cred=Get-Credential
foreach ($group in $group_list)
{
try {
$destUrl = $group.SiteName #Read-Host "Enter the destination site url"
$tempFile = [System.IO.Path]::GetTempFileName();
Export-PnPClientSidePage -Force -Identity $pageName -Out $tempFile
Connect-PnPOnline -Url $destUrl -Credentials $cred
Invoke-PnPSiteTemplate -Path $tempFile
$group.SiteName
Write-Host "ModernPage is successfully copied."
sleep 10
Set-PnPHomePage -RootFolderRelativeUrl "sitepages/Home-Team.aspx"#$pageName
} catch {
$group.SiteName
Write-Host -ForegroundColor Red 'Error ', ':'
$Error[0].ToString();
sleep 10
}
}
Wednesday, March 9, 2022
Add all users except guest account as a Sharepoint online site viewer access
$SiteURL = "https://test.sharepoint.com/sites/team" Connect-PnPOnline -Url $SiteURL -UseWebLogin $Group = Get-PnPGroup -AssociatedVisitorGroup $User = "Everyone except external users" Add-PnPGroupMember -LoginName $User -Identity $Group
Monday, September 6, 2021
Create Headerless search result plage
#1)Create a page with normal layout in SharePoint Connect-PnPOnline https://shared.sharepoint.com/sites/IT Get-PnPClientSidePage -Identity results Set-PnPClientSidePage -Identity results -LayoutType HeaderlessSearchResults
Saturday, September 4, 2021
Get the office 365 Compliance report
Install-Module -Name ExchangeOnlineManagement Import-Module ExchangeOnlineManagement $Credential = Get-Credential #-credential used to connect Azure AD $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking -AllowClobber $StartDate=(((Get-Date).AddDays(-30))).Date # Report for last 30 days $EndDate=Get-Date $Operation="UserLoggedIn" #Login details $Results=Search-UnifiedAuditLog -UserIds 'Abc@abc.com' -StartDate $StartDate -EndDate $EndDate -operations $Operation -ResultSize 1 |select UserIds , CreationDate $Results
Wednesday, May 19, 2021
Finding data in CSV file from other CSV file
#http://hilite.me/ #Create folder $Path = "C:\Temp\PowerShell - Enterprise\PSTN\90 days" # Location of file to be saved $PSTNLicenseUserSource = Import-Csv -Path "$($path)\PSTNLicenseUserDomesticlCalling120.csv" # CSV file having list of user with license $30DaysTeamsLogs = Import-Csv -Path "$($path)\TeamsLogs.csv" # CSV file downloaded from Teams logs for last 30 days $Datetime= Get-Date -Format dd_MM_yyyy_HH.mm.ss $LogFileName=([string]::Concat("$($path)\Teams_Report " , $Datetime ,".csv")) New-Item $LogFileName -ItemType file Add-Content $LogFileName -Value ([string]::Concat("Email"+","+ "Total Call" +","+ "Accessed in 30 days Yes/No")) ForEach ($PSTNLicenseUser in $PSTNLicenseUserSource) { $30DaysTeamLogsSingleUserData = $30DaysTeamsLogs | where {$_.UPN -eq $PSTNLicenseUser."User principal name" } $DataMatchInTeamsLogs = $30DaysTeamLogsSingleUserData | Select-Object -first 1 If($DataMatchInTeamsLogs) # If record gets found { #Write-Host $DataMatchInTeamsLogs.UPN -ForegroundColor green #Add-Content $LogFileName -Value ([string]::Concat($($DataMatchInTeamsLogs.UPN) +","+ $($DataMatchInTeamsLogs."Duration Seconds") +","+ "Yes")) } else #Unable to find the record { Write-Host $PSTNLicenseUser."User principal name" -ForegroundColor white Add-Content $LogFileName -Value ([string]::Concat($($PSTNLicenseUser."User principal name") +","+ "0" +","+ "No")) } }
Friday, March 26, 2021
Azure AD service principal enterprise app disable
try { $var = Get-AzureADTenantDetail } catch [Microsoft.Open.Azure.AD.CommonLibrary.AadNeedAuthenticationException] { Write-Host "You're not connected."; Write-Host -ForegroundColor Red " *** Error With Azure AD Connection **" $Credential = Get-Credential #-credential used to connect Azure AD Connect-AzureAD -Credential $Credential } $Path = "C:\Temp\PowerShell - Enterprise\Process" # Location of file to be saved Get-AzureADServicePrincipal -All $true | Export-Csv -Path ""$($path)\Processes.csv"" -NoTypeInformation # Pull the list of all enterprise apps in the Tenant $AppListSource = Import-Csv -Path "$($path)\Processes.csv" # Read the CSV file having list of all Apps name , $Datetime= Get-Date -Format dd_MM_yyyy_HH.mm.ss $LogFileName=([string]::Concat("$($path)\Apps_Report " , $Datetime ,".csv")) New-Item $LogFileName -ItemType file Add-Content $LogFileName -Value ([string]::Concat("Application Display Name"+","+ "Oject ID" +","+ "App ID"+","+ "Application Access Dates"+","+ "UserPrincipalName")) ForEach ($AppNameSource in $AppListSource) { $varAppId = $AppNameSource.AppId $LoginDetails = Get-AzureAdAuditSigninLogs -top 1 -filter "AppId eq '$varAppId'" | select CreatedDateTime, userprincipalname Write-Host $AppNameSource.DisplayName "--" $LoginDetails.userprincipalname -ForegroundColor white Add-Content $LogFileName -Value ([string]::Concat($($AppNameSource.DisplayName) +","+ $($AppNameSource.ObjectId) +","+ $($AppNameSource.AppId)+","+ $LoginDetails.CreatedDateTime+","+ $LoginDetails.userprincipalname)) $value = $LoginDetails.userprincipalname if ( $value -ne $null ) { $appId = $AppNameSource.AppId # Check if a service principal already exists for the app $servicePrincipal = Get-AzureADServicePrincipal -Filter "appId eq '$appId'" if ($servicePrincipal) { # Service principal exists already, disable it Set-AzureADServicePrincipal -ObjectId $servicePrincipal.ObjectId -AccountEnabled $false } } }
Friday, March 19, 2021
Last login details report from the Azure AD enterprise apps
#Connect with Azure AD UserPrincipalName try { $var = Get-AzureADTenantDetail } catch [Microsoft.Open.Azure.AD.CommonLibrary.AadNeedAuthenticationException] { Write-Host "You're not connected."; Write-Host -ForegroundColor Red " *** Error With Azure AD Connection **" $Credential = Get-Credential #-credential used to connect Azure AD Connect-AzureAD -Credential $Credential } $Path = "C:\Temp\PowerShell - Enterprise\Process" # Location of file to be saved Get-AzureADServicePrincipal -All $true | Export-Csv -Path ""$($path)\Processes.csv"" -NoTypeInformation # Pull the list of all enterprise apps in the Tenant $AppListSource = Import-Csv -Path "$($path)\Processes.csv" # Read the CSV file having list of all Apps name , $Datetime= Get-Date -Format dd_MM_yyyy_HH.mm.ss $LogFileName=([string]::Concat("$($path)\Apps_Report " , $Datetime ,".csv")) New-Item $LogFileName -ItemType file Add-Content $LogFileName -Value ([string]::Concat("Application Display Name"+","+ "Oject ID" +","+ "App ID"+","+ "Application Access Dates"+","+ "UserPrincipalName")) ForEach ($AppNameSource in $AppListSource) { $varAppId = $AppNameSource.AppId $LoginDetails = Get-AzureAdAuditSigninLogs -top 1 -filter "AppId eq '$varAppId'" | select CreatedDateTime, userprincipalname Write-Host $AppNameSource.DisplayName "--" $LoginDetails.userprincipalname -ForegroundColor white Add-Content $LogFileName -Value ([string]::Concat($($AppNameSource.DisplayName) +","+ $($AppNameSource.ObjectId) +","+ $($AppNameSource.AppId)+","+ $LoginDetails.CreatedDateTime+","+ $LoginDetails.userprincipalname)) }
Compare two CSV file Data
$Path = "C:\Temp\PowerShell - Enterprise\Final" # Location of file to be saved $AppListSource = Import-Csv -Path "$($path)\AppList.csv" # CSV file having list of all Apps name , "Apps to review" tab $30DaysAppLogs = Import-Csv -Path "$($path)\Logs.csv" # CSV file downloaded from Azure Apps logs for last 30 days $Datetime= Get-Date -Format dd_MM_yyyy_HH.mm.ss $LogFileName=([string]::Concat("$($path)\Apps_Report " , $Datetime ,".csv")) New-Item $LogFileName -ItemType file Add-Content $LogFileName -Value ([string]::Concat("Application Name"+","+ "Oject ID" +","+ "Accessed in 30 days Yes/No")) ForEach ($AppNameSource in $AppListSource) { $TempData = $30DaysAppLogs | where {$_.Target1DisplayName -eq $AppNameSource.Target1DisplayName } $DataMatch = $TempData | Select-Object -first 1 If($DataMatch) { Write-Host $DataMatch.Target1DisplayName -ForegroundColor white Add-Content $LogFileName -Value ([string]::Concat($($DataMatch.Target1DisplayName) +","+ $($DataMatch.Target1ObjectId) +","+ "Yes")) } else { Write-Host $DataMatch.Target1DisplayName -ForegroundColor white Add-Content $LogFileName -Value ([string]::Concat($($AppNameSource.Target1DisplayName) +","+ $($AppNameSource.Target1ObjectId) +","+ "No")) } }
MFA Report
$loginURL = "https://login.microsoftonline.com" $resource = "https://graph.microsoft.com" $ClientSecret="qA-.-tt1A3rlu_4pe" $ClientID="6301d5-e-45-6b4675a9a" # App id $TenantName="test.onmicrosoft.com" #Repeating Function to get an Access Token based on the parameters: function RefreshToken($loginURL,$ClientID,$clientSecret,$tenantName) { $body = @{grant_type="client_credentials";client_id=$ClientID;client_secret=$ClientSecret;scope="https://graph.microsoft.com/.default"} $oauthResponse = Invoke-RestMethod -Method POST -Uri $loginURL/$TenantName/oauth2/v2.0/token -Body $body return $oauthResponse } #BUILD THE ACCESS TOKEN $oauth=RefreshToken -loginURL $loginURL -resource $resource -ClientID $ClientID -clientSecret $ClientSecret -tenantName $TenantName $Identity = $oauth.access_token #$ClientSecret1 = "qA-.-tDjp6n5Wc9d84~tmset1A3rlu_4pe" #$ClientSecret = ConvertTo-SecureString -String $ClientSecret1 -AsPlainText -Force #$Token = Get-MsalToken -clientID $ClientID -tenantID $tenantId -Scope 'https://graph.microsoft.com/Policy.Read.All' -RedirectUri "https://login.microsoftonline.com/common/oauth2/nativeclient" -clientsecret $ClientSecret #$Identity = $Token.AccessToken $headerParams = @{'Authorization'="$($oauth.token_type) $($Identity)"} $CAPolicies = "https://graph.microsoft.com/beta/conditionalAccess/policies" #$CAPolicies = "https://graph.microsoft.com/beta/conditionalAccess/policies/06108f32-1950-4342-ae8f-968121a366d4" $apirequest = (Invoke-WebRequest -Headers $headerParams -Uri $CAPolicies -Method GET) $Logs = @() foreach ($event in ($apirequest.Content | ConvertFrom-Json| select -ExpandProperty value)) { $Log = New-Object System.Object $Log | Add-Member -MemberType NoteProperty -Name "Policy ID" -Value $event.id $Log | Add-Member -MemberType NoteProperty -Name "Policy Name" -Value $event.displayName $Log | Add-Member -MemberType NoteProperty -Name "Policy State" -value $event.state $Log | Add-Member -MemberType NoteProperty -Name "Policy Last Updated Time" -value $event.modifiedDateTime $Log | Add-Member -MemberType NoteProperty -Name "Policy Session Controls App Enforced Restrictions" -Value $event.sessionControls.applicationEnforcedRestrictions $Log | Add-Member -MemberType NoteProperty -Name "Policy Session - CA App Control" -value $event.sessionControls.cloudAppSecurity $Log | Add-Member -MemberType NoteProperty -Name "Policy Session - Sign in Frequency" -value $event.sessionControls.signInFrequency $IncludedUsers = $event.conditions.users.includeUsers -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Included Users" -Value $IncludedUsers $ExcludedUsers = $event.conditions.users.excludeUsers -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Excluded Users" -Value $ExcludedUsers $IncludedGroups = $event.conditions.users.includeGroups -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Included Groups" -Value $IncludedGroups $ExcludedGroups = $event.conditions.users.excludeGroups -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Excluded Groups" -Value $ExcludedGroups # $IncludedRoles = $event.conditions.users.includeRoles -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Included Roles" -Value $IncludedRoles $ExcludedRoles = $event.conditions.users.excludeRoles -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Excluded Roles" -Value $ExcludedRoles $IncludedApps = $event.conditions.applications.includeApplications -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Included Applications" -value $IncludedApps $ExcludedApps = $event.conditions.applications.excludeApplications -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Excluded Applications" -value $ExcludedApps $IncludedUserActions = $event.conditions.applications.includeUserActions -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy User Actions" -value $IncludedUserActions $ClientTypes = $event.conditions.clientAppTypes -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - Client Apps " -value $ClientTypes $IncludedDevices = $event.conditions.devices.includeDeviceStates -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - Included Device States" -Value $IncludedDevices $ExcludedDevices = $event.conditions.devices.excludeDeviceStates -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - Excluded Device States" -Value $ExcludedDevices $IncludedLocations = $event.conditions.locations.includeLocations -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - Included Locations" -value $IncludedLocations $ExcludedLocations = $event.conditions.locations.excludeLocations -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - Excluded Locations" -value $ExcludedLocations $IncludedPlatforms = $event.conditions.platforms.includePlatforms -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - Included Device Platforms" -value $IncludedPlatforms $ExcludedPlatforms = $event.conditions.platforms.excludePlatforms -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - Excluded Device Platforms" -value $ExcludedPlatforms $SignInRiskLevels = $event.conditions.signInRiskLevels -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - SignInRiskLevels" -Value $RiskLevels $UserRiskLevels = $event.conditions.userRiskLevels -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Conditions - UserRiskLevels" -value $UserRiskLevels $BuildInControls = $event.grantControls.builtInControls -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Controls" -Value $BuildInControls $AuthFactors = $event.grantControls.customAuthenticationFactors -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Auth Factors" -value $AuthFactors $TermsOfUse = $event.grantControls.termsOfUse -join "; " $Log | Add-Member -MemberType NoteProperty -Name "Policy Terms Of Use" -value $TermsOfUse $Logs += $Log } Write-host "Add the Path you'd like us to export the CSV file to, in the format of <c: sers="">\Desktop\Users.csv>" -ForegroundColor white -BackgroundColor Black $Logs | Export-CSV "C:\Temp\MFA Report\Results.csv" -NoTypeInformation -Encoding UTF8 </c:>
Thursday, March 18, 2021
Get the list of all Azure AD enterprise application list
Connect-AzureAD Get-AzureADServicePrincipal -All $true Get-AzureADServicePrincipal -All $true | Export-Csv -Path "C:\Temp\PowerShell - Enterprise\Processes.csv" -NoTypeInformation
Wednesday, February 17, 2021
Check CsTeamsMeetingPolicy
$adminUPN="ABC@Test.onMicrosoft.com" $userCredential = Get-Credential -UserName $adminUPN -Message "Type the password." $sfbSession = New-CsOnlineSession -Credential $userCredential Import-PSSession $sfbSession Get-CsTeamsMeetingPolicy | Select-Object -Property Identity, RecordingStorageMode
# Below updated code
Install-Module -Name MicrosoftTeams -Force -AllowClobber $credential = Get-Credential Connect-MicrosoftTeams -Credential $credential Get-CsTeamsMeetingPolicy | Select-Object -Property Identity, RecordingStorageMode
Sunday, January 31, 2021
Add user to Azure Data lake workspace Group using PowerShell
$GroupdID = "7519627166" # ID of the group where users need to be added as a member $bearer_token = "dapi4defcba7682aff5-2" $workspaceURL ="https://adb-85238717.17.azuredatabricks.net" #---------------------------------------------------------------------------------------- $url = "$workspaceURL/api/2.0/preview/scim/v2/Groups/$GroupdID" $headers = @{Authorization = "Bearer $bearer_token"} $par = '{ "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"add", "value":{ "members":[ { "value": "287484517 - ID of the user which needs to be added into above group" } ] } } ] }' Invoke-WebRequest $url -Method PATCH -Headers $headers -Body $par -ContentType 'application/json'
Get the list of user details for Azure Data lake workspace
$bearer_token = "dapi4de9600e2aff5-2" $headers = @{"Authorization"= "Bearer $bearer_token" "Content-Type" = "application/json" } $hosturl="https://adb-8523889618.17.azuredatabricks.net" $uri="$hosturl/api/2.0/preview/scim/v2/Users" Invoke-RestMethod -Method 'Get' -Uri $uri -Headers $headers
Wednesday, January 27, 2021
Add user to Azure Data lake using Powershell with Admin access role.
# Script to add the user to Azure Data Lake workspace with allow-cluster-create access $url = "https://adb-5890072754.14.azuredatabricks.net/api/2.0/preview/scim/v2/Users" $groupid= "736317399920" # Get the Admin ID from the other script $bearer_token = "dapie53ab46ca47e3e3a69f12a75c6-2" $headers = @{Authorization = "Bearer $bearer_token"} $par = '{ "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "userName":"databrickser-2@globeduc.onmicrosoft.com", "displayName":"User 2", "groups":[ { "value":"$groupid" } ] }' Invoke-WebRequest $url -Method Post -Headers $headers -Body $par -ContentType 'application/json'
Subscribe to:
Posts (Atom)
HTML
Script: