azure automation
50 TopicsConvert a text string to a correct date time format
Hello folks, I have maybe a simple question for the experienced people around here 🙂 . I have a runbook in azure that is getting the field "CreatedDateTime" of a unified group (Teams Team). The format of this field ist like the following "2020-08-06T06:03:19Z". This is not recognized as a valid DateTime format by the cmdlet: $DateTime=[Datetime]::ParseExact($DateTime, 'MM/dd/yyyy', $null) Can anyone point me to a solution how to get the string "2020-08-06T06:03:19Z" into a string like "2020-08-06" or "06-08-2020". Every hint is appreciated. Thank you all 😉Solved38KViews0likes4CommentsCompare two csv files
Hello I am trying to get an idea of devices that have not enrolled in Intune, but are accessing exchange online. I am using two .csv files. The intune file contains all devices that have enrolled in intune and the Exchange file contains all devices that are currently found in Exchange online. I want to compare the two files and export the differences to another .csv file. The two files share a common attribute "deviceid" Thank you in advance for any guidance $Intune = import-csv .\intune.csv | Group-Object -AsHashTable -AsString -Property 'DeviceID' $Exchange = import-csv .\mobiledevicereport.csv | Group-Object -AsHashTable -AsString -Property 'DeviceID'Solved22KViews0likes2CommentsInstall-Module MSOnline - not working
Hi all, I am struggling to install: Install-Module MSOnline I get: I have tried: Get-PSRepository WARNING: Unable to find module repositories. When I run: Register-PSRepository -Default I get no error but when trying to run Get-PSRepository again i get WARNING: Unable to find module repositories. Any ideas on how to fix this?Solved21KViews0likes1CommentIs there a way to reset/wipe all data from M365 user accounts in order to re-use the same accounts?
Dear all, I apologize in advance if I am posting my question in the wrong place. Every year we have external people coming to our campus who need to access specific school resources just for a few months. We have created several accounts for them with policy restrictions and we are happy with this solution. We were wondering if there is a way to automate the deletion of all their data (mainly OneDrive files/Outlook emails) at the end of their stay here in order to keep those accounts clean for the upcoming persons. We don't want to do this task manually. Is it quicker to delete the accounts and re-create them every year? Many thanks in advance for any help FrancescoSolved6KViews0likes9CommentsScript to convert .log files to JSON
Recently setup a pipeline from AWS S3 to our SIEM (Microsoft Sentinel) using a lambda function to ingest our AWS WAF logs. There is a succesful connection between the two but I noticed that the logs weren't being pushed. The logs are stored in .log format and after converting the format to JSON they went through and I could see them in the SIEM. The problem is we had to do this manually and need to find a way to automate this. Is there a powershell script that could automate the conversion of a .log file to JSON? The lambda function is a powershell script so this would be easy to add.5.9KViews0likes1CommentCreate Named Location list using PowerShell
Hello Community, I am trying to build a PowerShell script that will create a Named Location in Azure AD with multiple IP ranges. Here: New-AzureADMSNamedLocationPolicy (AzureAD) | Microsoft Docs I see an example with only one IP range, it works nice. But how can I add multiple IP ranges from a csv file, for example? I've tried several options with Import-CSV and arrays, but haven't succeeded. Could anybody advise me on how to push a list of IP ranges into the Named Location? This is what I have so far: Connect-AzureAD $ipRanges = New-Object -TypeName System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.IpRange] $IPAddressesList = Import-CSV C:\IPs.csv foreach ($IP in $IPAddressesList) { $ipRanges.Add($IP) } New-AzureADMSNamedLocationPolicy -OdataType "#microsoft.graph.ipNamedLocation" -DisplayName "IP named location policy" -IsTrusted $false -IpRanges $ipRangesSolved5.9KViews0likes8CommentsExtracting Virtual Machine Information in Azure.
I just want to shared my modified code in azure vm information extraction. Data will be the list of VMName, IPAddress, ResourceGroup, VmSize & Tag. # User Authentication $ua = Get-StoredCredential -Target AzureAccount $credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $ua.UserName,$ua.Password # Login to your Azure Account Connect-AzAccount -Tenant '<Tenant ID>' -Credential $credential # Get All Virtual Machines & VMSize $resultVMs = Get-AzVM | Where-Object { $_.Name -and $_.ResourceGroupName -and $_.HardwareProfile.VmSize } ` | Select-Object -Property @{n="Resource"; e={ $_.ResourceGroupName }}, @{n="VMName"; e={ $_.Name }}, @{n="VmSize"; e={ $_.HardwareProfile.VmSize }} ` # Get All Virtual Machines & WorkNo Tag $resultTags = Get-AzResource -ResourceType "Microsoft.Compute/virtualMachines" ` | Where-Object { $_.Name -and $_.ResourceGroupName -and $_.Tags.WorkNo } ` | Select-Object -Property @{n="Resource"; e={ $_.ResourceGroupName }}, @{n="VMName"; e={ $_.Name }}, @{n="Tags"; e={ $_.Tags.WorkNo }} ` # Get All Virtual Machines & Ip Address $resultIPAdds = Get-AzNetworkInterface | Where-Object { $_.ResourceGroupName -and $_.VirtualMachine -and $_.IPConfigurations -and $_.IPConfigurations.PrivateIPAddress } ` | Select-Object -Property @{n="Resource"; e={ $_.ResourceGroupName }}, @{n="VMName"; e={ $_.VirtualMachine.Id.Split("/")[-1] }}, @{n="PrivateIPAddress"; e= { $_.IpConfigurations.PrivateIPAddress }} ` # Create Report Array $report = @() # Loop All VM's foreach($resultVM in $resultVMs){ # Creating Report Header $reportdetails = "" | Select VMName, IPAddress, ResourceGroup, VmSize, Tag # Save the VM Name $reportdetails.VMName = $resultVM.VMName # Save the Resource Group Name $reportdetails.ResourceGroup = $resultVM.Resource # Save the VmSize $reportdetails.VmSize = $resultVM.VmSize # Save the IP Address $temp = @(($resultIPAdds | Where-Object { $_."VMName" -match $resultVM.VMName }).PrivateIPAddress) $reportdetails.IPAddress = $temp[0] # Save the Tag $temp = @(($resultTags | Where-Object { $_."VMName" -match $resultVM.VMName }).Tags) $reportdetails.Tag = $temp[0] # Save Report $report+=$reportdetails } # Generate Report $report | Export-Excel ".\Desktop\VMList_ $(get-date -f yyyy.MM.dd.HH.mm.ss).xlsx" Write-Host "Finished..." Hope it can help others too. 😁😁😁.3.8KViews1like4CommentsHow can I use a System Managed Identity with Connect-MsolService
Does anyone know how to use Connect-MsolService with a system-assigned managed identity? I need it for the purpose of getting MFA status data about the organisation's employees. MSGraph seems to have zero data on this, except for the User Registration Details report, which again does not show MFA status.3.4KViews0likes11CommentsDo you have any faster ps script to get azure private ip address?
Hi Community, Do you have any faster ps script to get azure private ip address? Extracting too many vms makes this script slow. Thanks. My Code. $nin = (Get-AzVM -Name "VMNAME").NetworkProfile.NetworkInterfaces.Id.Split("/")|Select -Last 1 $ips = (Get-AzNetworkInterface -Name $nin).IpConfigurations.PrivateIpAddress $ipsSolved3.3KViews0likes5Comments