Intune - exporting a list of users with more than one Windows device - endpoint

I have more than 1100 Windows devices registered on Intune, some users had their laptop replaced, however the device replaced was not deleted. How can I generate a list of UPN that contains more than 1 device? I will need this check this list and then remove it from On-Prem AD, AAD, Intune.
I was trying to create a PowerShell script, but I am not finding a way to do that.
$intuneDevices = Get-IntuneManagedDevice | Get-MSGraphAllPages
$windevices = $intuneDevices | Where-Object { $.operatingSystem -eq "Windows" }
$windevices | **Where-Object {$.userPrincipalName -ge '1'}* | Select DeviceName, userPrincipalName
*
I am not sure exactly how I can bring userPrincipalName with more than 1 device.
I hope it make sense and someone can help
Thanks in advance
TZ

Related

ESXi VM snapshot creation | PowerCLI

I'm trying to automate snapshot checking DS free space. Its getting tricky for VMs with multiple DS attached. Script takes multiple snapshots for such VMs if condition satisfies. Please help me to understand where its going wrong.
Consolidating free space:
$free = (Get-Datastore -VM $vm | Select #{N="FreeSpace";E={[math]::Round(($_.FreeSpaceMB)*100/($_.CapacityMB),0)}})
Now checking if free space is available in each DS where VM connected:
foreach ($ds in $free.FreeSpace)
{
if (($ds -gt 25)
{
get-vm $vm | new-snapshot -name "$cmr.$date" -Description $description
}
}
If I understand the question properly, regarding dealing with multiple datastores... I would take a look at introducing a Sort-Object after the initial Get-Datastore which is based on the FreeSpaceMB property, then only selecting the first datastore (which should have the least amount of free space available) and performing your calculation based on that.
Untested example:
$free = (Get-Datastore -VM $vm | Sort-Object -Property FreeSpaceMB | Select-Object -Property #{N="FreeSpace";E={[math]::Round(($_.FreeSpaceMB)*100/($_.CapacityMB),0)}} -First 1)

PowerCli - cannot filter Virtual Machines by VMHost property

I'm experimenting for the first time PowerCli on my VSphere environment.
I'm trying the Get-Vm filtering the results in this way and it's working fine:
Get-Vm | where MemoryGB -eq "8"
but if I try the same syntax, filtering by VMHost property, I don't get any result:
Get-Vm | where VMHost -eq "10.0.0.30"
But I have a lot of machines on the host 10.0.0.30, why it's not working?
I can see it if I use this syntax that filters the text output in the end:
Get-Vm | select name,vmhost | findstr -i .30
what I'm doing wrong?
thanks
The VMHost property that you're referring to is actually a VMHost object, so you may have to filter something like Get-VM | where {$_.VMHost.Name -eq '10.0.0.30'} in order to do a string vs. string comparison.
Get-VMHost -Name "10.0.0.30" | Get-VM
VMHost has the property "Name".
So you can pass the name(ip) of VMHost and get the list of all vms on the hosted ip.
Link to cmndlet explanation: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/6fb85470-f6ca-4341-858d-12ffd94d975e/4bee17f3-579b-474e-b51c-898e38cc0abb/doc/Get-VMHost.html#:~:text=Suspend%2DVMHost-,This%20cmdlet%20retrieves%20the%20hosts%20on%20a%20vCenter%20Server%20system,one%2C%20use%20the%20Server%20parameter.

Regex to match last sentence of a line

Got some text:
[23/07 | DEV | FARO | QC Billable | #2032] Unable to Load label
[30/07 | QC | ROLAWN ] Selling products as a bundle
[11/08 | EST | QC BILLABLE | #2015 ISUOG ] On Demand website looping
[05/08 | EST | ROLAWN | Problems with 'find a stockist'
[29/07 | DEV | QUBA] Blog comments loading to error
[24/07 | FROG | EST| QC BILLABLE #2033] Carousel banner not working correctly
I'm trying to match the last sentence at the end of each line so the matches are as follows:
Unable to Load label
Selling products as a bundle
On Demand website looping
Problems with 'find a stockist'
Blog comments loading to error
Carousel banner not working correctly
Unfortunately, I can't depend on the structure of the line to conform, but the information I'm trying to extract should always be the last sentence. I've tried quite a few different things, but I'm struggling here.
If there is also some kind on no-word character before last sentence, try with:
[\w\s']+$
DEMO
Edit: The answer above by m.cekiera [\w\s']+$ is better.
](.+)$
Here's a pretty naive solution: https://regex101.com/r/yT8jJ7/1.
If you give more details about the actual structure it could be refined.

Powershell add-adgroupmember from variable with multiple values.

Background.
Powershell command pulling Sharepoint List distro data from a multichoice column.
$EmailDistro= ($listitem.Fields["Email Distribution List Membership"]).getfieldvalueastext($listitem["Email Distribution List Membership"])
$EmailDistros = Distro1,Distro2,Distro3
Command I would like to run.
"$emaildistros" | add-adgroupmember -member jdoe
Unfortunately this translates to
Distro1,Distro2,Distro3 | add-adgroupmember -member jdoe
but I need it like this.
"Distro1","Distro2","Distro3" | Add-adgroupmemeber -member jdoe
I am open to workarounds.
Thanks!
It looks like the result your getting back from Sharepoint is a string containing all the groups and not an array. Split the result you get back into an explicit array:
$EmailDistros = $EmailDistros -split ","
Then you can pipe the array like you'd expect:
$EmailDistros | Add-ADGroupMember -member jdoe
You could also do more with each distro:
$EmailDistros | % { Add-ADGroupMember -member jdoe }

C++ - basic Qt question

Do I have any simple way to have context menu items, that aren't highlighted when mouse goes over them (using Qt)?
I want to make simple context menu with various item groups such as
| Group1
| -----
| DoSomething
| DoSomethingWow
| DoSomethingCool
|
| Group2
| ------
| DoSomethingCoolHuh
and I want Group1 and Group2 act as simple labels so that users couldn't even focus them.
Is this possible?
simple solution which comes to my mind "out of the box" is to:
set those items disabled:
item.setEnable(False)
Then you could use some style to make it look different.
Hope this helps.