azure
91 TopicsExport Enterprise apps and signin count
I need to export all the configured enterprise apps and login count for each. This script does the job, but it truncates the application name (see example screen shot) and I can't figure out how to export the results to csv. Can anyone help? #To enable verbose [CmdletBinding()] Param() #Retrieve list of applications $Apps = Get-AzureADApplication #Loop through each application ForEach($App in $Apps){ Write-Verbose "Processing $($App.DisplayName)" #Retrieve logs filtered on AppID $Log = Get-AzureADAuditSignInLogs -All $true -filter "appid eq '$($App.AppID)'" #Create a custom object for output [PSCustomObject]@{ ApplicationName = $App.DisplayName ApplicationID = $App.AppID SignIns = $Log.count } #To prevent throttling on Sign-in Log querying, insert a sleep Start-Sleep 1 }226Views0likes3CommentsPowershell Script to extract Azure VM Metrics data
Hi Community, hope you are doing well. I am currently playing around with powershell scripting and trying to extract Azure VM utilization data usingGet-AzMetric powershell module. I am trying to extract VM metrics through my script for all VMs in my current subscription (free trial) and outputting the same to a csv file. I can see the data getting extracted when I run in console but when I run the script I am unable to see the data getting outputted to my csv file. Please find below my script: # Modules importation #$modules = 'Az.Accounts','Az.Compute', 'Az.Reservations' , 'Az.Storage' , 'Az.Billing' ,'Az.BillingBenefits' ,'Az.Monitor','Az.ResourceGraph', 'Join-Object' ,'PSExcel' ,'Az.Resources', 'Az.CostManagement','ImportExcel' # PS Module required #Install-Module -Name $modules -Scope CurrentUser -Force #Powershell-5.1 # Suppress breaking changes Set-Item Env:\SuppressAzurePowerShellBreakingChangeWarnings "true" # Connect to Azure Connect-AzAccount # Name of the analyze [void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') $title = ' Azure VM Usage' $msg = 'Please enter the name of the analyze:' $checklistname = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title) # Subscription(s) selection - CTRL & click to select more than 1 subscription $subquery = (Get-AzSubscription | Out-GridView -Title "Select an Azure Subscription" -PassThru) $sub = $subquery.Id Write-Host "Subscription(s) selected: $sub" -ForegroundColor Green # Creation of the directroy New-Item -Path "c:\" -Name "Azurecost\$checklistname" -ItemType "directory" -force set-location c:\azurecost\$checklistname #$csvFileVM = New-Object System.IO.StreamWriter("c:\azurecost\$checklistname\VM-Usage.csv") #$csvFileVM.WriteLine("Name, Id, ResourceGroup, MaxCPU") foreach ($subscription in $sub) { # Set the subscription context Set-AzContext -Subscription $subscription $vms = Get-AzVM $vmUtilizationData = @() # Loop through each VM to get utilization metrics foreach ($vm in $vms) { $vmName = $vm.Name $resourceId = $vm.Id $Resourcegroup = $vm.ResourceGroupName # Get metrics for the VM (e.g., CPU Percentage) $metric = Get-AzMetric -ResourceId $resourceId -MetricName "Percentage CPU" -TimeGrain 12:00:00 -StartTime (Get-Date).AddDays(-3) -EndTime (Get-Date) $MaxCPU = $metric.data.maximum | Measure-Object -Maximum | Select-Object -property Maximum #$csvFileVM.WriteLine(" $MaxCPU") $vmUtilizationData += [PSCustomObject]@{ VMName = $vmName ResourceGroup = $Resourcegroup MaxCPU = $MaxCPU } } } $vmUtilizationData | Export-Csv -Path "c:\Azurecost\$checklistname\VMUsage.csv" -NoTypeInformation Write-Host "Your script has finished running." pause Please help me understand what am I missing here since other details like VM name, Resource group name are getting outputted to my csv file through this script except the metric values.173Views0likes0Comments[resolved] Variables are not consistent
Hello internet. My mind is completely blown by this! I have a PowerAutomate that sets some 'compose' actions and then uses them to start a job. It is a PowerShell 7.2 script running in a Runbook extension-based hybrid worker on a Debian 11 Azure VM. I've reduced the script to just printing the inputted variable values. That's all, yet it provides them transposed! param ( [string] $siteNAME, [string] $OMd, [string] $userNAME, [string] $templateNAME ) $scriptVERSION = "x.y.z" function WO { write-output $wriOU } write-output "----------------------------------" $wriOU = "siteNAME: "+$($siteNAME);WO $wriOU = "OMd: "+$($OMd);WO $wriOU = "userNAME: "+$($userNAME);WO $wriOU = "templateNAME: "+$($templateNAME);WO write-output "----------------------------------" $wriOU = "Script Version: [ "+$scriptVERSION+" ]";WO write-output "-end of line-" #EOF As you can see 'siteNAME' retains the value correctly. But then 'OMd', 'username', and 'templateNAME' goes sideways so hard... Why? What am I doing wrong, this seems super odd... Any insight is greaaaatly appreciated. TY!Solved332Views0likes2CommentsUsing powershell to create folders within users onedrive
Hi all, I'm experiencing several issues with different PowerShell versions when trying to create folders in OneDrive for users in bulk. PowerShell 5.1 does not recognize Connect-PnPOnline. PowerShell 7 does not recognize Connect-SPOService. I have been following the instructions from this guide, which worked on my previous device. However, I’m unable to get it to work on my new device. My goal is to create folders within specific users' OneDrive accounts. Could you please assist me in resolving this? Thank you!2.4KViews0likes26CommentsSet exchange policy with filter?
I am trying to figure out how to run a command to create a exchange online emailadresspolicy. New-EmailAddressPolicy -Name Groups1 -IncludeUnifiedGroupRecipients -EnabledEmailAddressTemplates "SMTP:@santa.mycompany.com","smtp:@santa.mycompany.com" -RecipientFilter {mailNickname -like 'Santa_*'} -Priority 1 I want all groups that are that have a mailnickname that starts with "Santa_" to be created with a specific subdomain. I can not create it tho, i get error that recipientFilter is not a valid attribute. New-EmailAddressPolicy: A parameter cannot be found that matches parameter name 'RecipientFilter'. i have also tried ConditionalCustomAttribute1 but get the same error: anyone able to help?437Views0likes5CommentsWhat Causes 🅠🅤🅘🅒🅚🅑🅞🅞🅚🅢 Online Error Code 101 and How Can It Be Fixed?
🅠🅤🅘🅒🅚🅑🅞🅞🅚🅢 Online Error Code 101 typically occurs due to a problem connecting to your bank account. Causes include incorrect bank login credentials, outdated browser settings, or connectivity issues. To fix it: Verify Login Information: Ensure your bank login credentials are correct. Update Browser: Use the latest version of your web browser. Clear Cache and Cookies: Clear your browser's cache and cookies. Check Bank's Website: Verify there are no issues with the bank's website. Reconnect Account: Disconnect and reconnect your bank account in 🅠🅤🅘🅒🅚🅑🅞🅞🅚🅢. If the issue persists, contact 🅠🅤🅘🅒🅚🅑🅞🅞🅚🅢 support.563Views0likes1CommentError - Connect-ExchangeOnline Error Acquiring Token: System.Net.Http.HttpRequestException
Error Connect-ExchangeOnline Error Acquiring Token: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Remote name could not be resolved: 'server.proxy.local'484Views0likes1CommentHow to get rid of warning 'Unable to acquire token for tenant 76a47f06...' with Connect-AzAccount?
How do I get rid of the warning 'WARNING: Unable to acquire token for tenant 76a47f06...' permanently and forever when I log in with 'Connect-AzAccount'? I have already deleted the file "C:\Users\RContosoUser\.Azure\AzureRmContext.json". No improvement. I have already logged in with 'Connect-AzAccount --UseDeviceAuthentication'. No improvement. I also tried 'Clear-AzContext' and 'Remove-AzContext'. No improvement. When I log in, I always get (partially anonymized here) the following message/warning: PS C:\Users\RContosoUser> Connect-AzAccount -UseDeviceAuthentication WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code DSU000000 to authenticate. WARNING: TenantId 'd4b72ec1' contains more than one active subscription. First one will be selected for further use. To select another subscription, use Set-AzContext. WARNING: Unable to acquire token for tenant '76a47f06' with error 'You must use multi-factor authentication to access tenant 76a47f06, please rerun 'Connect-AzAccount' with additional parameter '-TenantId 76a47f06'.' WARNING: Unable to acquire token for tenant '80fab529' with error 'SharedTokenCacheCredential authentication unavailable. Token acquisition failed for user email address removed for privacy reasons. Ensure that you have authenticated with a developer tool that supports Azure single sign on.' WARNING: Unable to acquire token for tenant '76a47f06' with error 'You must use multi-factor authentication to access tenant 76a47f06, please rerun 'Connect-AzAccount' with additional parameter '-TenantId 76a47f06'.' WARNING: Unable to acquire token for tenant '80fab529' with error 'SharedTokenCacheCredential authentication unavailable. Token acquisition failed for user email address removed for privacy reasons. Ensure that you have authenticated with a developer tool that supports Azure single sign on.' Account SubscriptionName TenantId Environment ------- ---------------- -------- ----------- email address removed for privacy reasons MPN - R ContosoUser d4b72ec1 AzureCloud I no longer have any access at all to the tenants '76a47f06' and '80fab529' mentioned in the warning. I cannot contact anyone there to remove me from the AAD user directory. So what can I do to get rid of these warnings?39KViews0likes8CommentsMicrosoft Business Standard - Manage with PowerShell?
Hi, Longtime Microsoft 365 admin but PowerShell & Azure newbie here. I have a need to to configure settings that only seem to be configurable via PowerShell (and not available in the Admin center GUI). However, everything I read seems to infer that PowerShell can be used just with Microsoft 365 Enterprise licenses. I would like to know whether PowerShell can be used with an organization that uses Business Basic and Business Standard licenses (Using Azure CloudShell and an Azure storage account)? Thank you!Solved412Views0likes2CommentsObject reference not set to an instance of an object - when splatting to a custom function
I've written a module for a specific O365 function - onboarding users to mobile in InTune. The module works, but I needed to add the ability for users to specify alternative credentials to run the module. To achieve this, I'm using the splat method, which enables me to add credentials in the hash table Unfortunately, I'm getting error "Object reference not set to an instance of an object" with this method and cannot understand why. The parameters appear to be passed through OK as I can print them to host, but the command doesn't like it. Hopefully it's something obvious. FYI, if I rem out@Params and use the $User variable, it will work. $Params = @{ User = $User } if ($Null -ne $Credential) {$Params.add('Credential', $Credential)} Try { get-EXOEnabled @Params #Custom function } Catch {...}Solved5.9KViews0likes5Comments