Intune Powershell Script to Set All Windows 10 Connectoins to UnMetered

[pastacode lang=”markdown” manual=”%23AllConnectionsUnMetered%0A%0A%23We%20need%20a%20Win32%20class%20to%20take%20ownership%20of%20the%20Registry%20key%0A%24definition%20%3D%20%40%22%0Ausing%20System%3B%0Ausing%20System.Runtime.InteropServices%3B%20%0A%20%0Anamespace%20Win32Api%0A%7B%0A%20%0A%20%20%20%20public%20class%20NtDll%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%5BDllImport(%22ntdll.dll%22%2C%20EntryPoint%3D%22RtlAdjustPrivilege%22)%5D%0A%20%20%20%20%20%20%20%20public%20static%20extern%20int%20RtlAdjustPrivilege(ulong%20Privilege%2C%20bool%20Enable%2C%20bool%20CurrentThread%2C%20ref%20bool%20Enabled)%3B%0A%20%20%20%20%7D%0A%7D%0A%22%40%20%0A%20%0AAdd-Type%20-TypeDefinition%20%24definition%20-PassThru%20%7C%20Out-Null%0A%5BWin32Api.NtDll%5D%3A%3ARtlAdjustPrivilege(9%2C%20%24true%2C%20%24false%2C%20%5Bref%5D%24false)%20%7C%20Out-Null%0A%20%0A%23Setting%20ownership%20to%20Administrators%0A%24key%20%3D%20%5BMicrosoft.Win32.Registry%5D%3A%3ALocalMachine.OpenSubKey(%22SOFTWARE%5CMicrosoft%5CWindows%20NT%5CCurrentVersion%5CNetworkList%5CDefaultMediaCost%22%2C%5BMicrosoft.Win32.RegistryKeyPermissionCheck%5D%3A%3AReadWriteSubTree%2C%5BSystem.Security.AccessControl.RegistryRights%5D%3A%3Atakeownership)%0A%24acl%20%3D%20%24key.GetAccessControl()%0A%24acl.SetOwner(%5BSystem.Security.Principal.NTAccount%5D%22Administrators%22)%0A%24key.SetAccessControl(%24acl)%0A%20%0A%23Giving%20Administrators%20full%20control%20to%20the%20key%0A%24rule%20%3D%20New-Object%20System.Security.AccessControl.RegistryAccessRule%20(%5BSystem.Security.Principal.NTAccount%5D%22Administrators%22%2C%22FullControl%22%2C%22Allow%22)%0A%24acl.SetAccessRule(%24rule)%0A%24key.SetAccessControl(%24acl)%0A%0ANew-ItemProperty%20-path%20%22HKLM%3A%5CSOFTWARE%5CMicrosoft%5CWindows%20NT%5CCurrentVersion%5CNetworkList%5CDefaultMediaCost%22%20-Name%20WiFi%20-PropertyType%20Dword%20-Value%201%20-Force%0ANew-ItemProperty%20-path%20%22HKLM%3A%5CSOFTWARE%5CMicrosoft%5CWindows%20NT%5CCurrentVersion%5CNetworkList%5CDefaultMediaCost%22%20-Name%203G%20-PropertyType%20Dword%20-Value%201%20-Force%0ANew-ItemProperty%20-path%20%22HKLM%3A%5CSOFTWARE%5CMicrosoft%5CWindows%20NT%5CCurrentVersion%5CNetworkList%5CDefaultMediaCost%22%20-Name%204G%20-PropertyType%20Dword%20-Value%201%20-Force%0ANew-ItemProperty%20-path%20%22HKLM%3A%5CSOFTWARE%5CMicrosoft%5CWindows%20NT%5CCurrentVersion%5CNetworkList%5CDefaultMediaCost%22%20-Name%20Ethernet%20-PropertyType%20Dword%20-Value%201%20-Force%0ANew-ItemProperty%20-path%20%22HKLM%3A%5CSOFTWARE%5CMicrosoft%5CWindows%20NT%5CCurrentVersion%5CNetworkList%5CDefaultMediaCost%22%20-Name%20Default%20-PropertyType%20Dword%20-Value%201%20-Force” message=”” highlight=”” provider=”manual”/] 

How to elevate existing powershell Windows to Local Admin ( UAC )

Add the below to the top of your script[pastacode lang=”markdown” manual=”if%20(!(%5BSecurity.Principal.WindowsPrincipal%5D%5BSecurity.Principal.WindowsIdentity%5D%3A%3AGetCurrent()).IsInRole(%5BSecurity.Principal.WindowsBuiltInRole%5D%20%22Administrator%22))%20%7B%20Start-Process%20powershell.exe%20%22-NoProfile%20-ExecutionPolicy%20Bypass%20-File%20%60%22%24PSCommandPath%60%22%22%20-Verb%20RunAs%3B%20exit%20%7D%0A%0A%23%20Your%20script%20here” message=”” highlight=”” provider=”manual”/]

Powershell – List group Memberships in 365 of Distribution groups and Unified groups

 [pastacode lang=”markdown” manual=”%24groups%3DGet-UnifiedGroup%0A%0Aforeach(%24group%20in%20%24groups)%0A%7B%0A%20%20%20%20Write-Host%20%22************************************************%22%0A%20%20%20%20Write-Host%20%22GroupName%3A%20%22%20%20%24group.DisplayName%0A%20%20%20%20Write-Host%20%22Email%3A%20%22%20%20%24group.primarySMTPAddress%0A%20%20%20%20Write-Host%20%22—%20Members%20—%22%0A%20%20%20%20%24membersOfGroup%3DGet-UnifiedGroupLinks%20-Identity%20%24group.Identity%20-LinkType%20Members%0A%20%20%20%20foreach(%24member%20in%20%24membersOfGroup)%0A%20%20%20%20%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20Get-Recipient%20-Identity%20%24member.Name%20%7C%20select%20PrimarySmtpAddress%20%7CFormat-Wide%20%0A%20%20%20%20%7D%0A%20%20%20%20%20%0A%7D%0A%0A%0A%24groups%3DGet-DistributionGroup%0A%0Aforeach(%24group%20in%20%24groups)%0A%7B%0A%20%20%20%20Write-Host%20%22************************************************%22%0A%20%20%20%20Write-Host%20%22GroupName%3A%20%22%20%20%24group.DisplayName%0A%20%20%20%20Write-Host%20%22Email%3A%20%22%20%20%24group.primarySMTPAddress%0A%20%20%20%20Write-Host%20%22—%20Members%20—%22%0A%20%20%20%20%24membersOfGroup%3DGet-DistributionGroupMember%20-Identity%20%24group.Identity%0A%20%20%20%20foreach(%24member%20in%20%24membersOfGroup)%0A%20%20%20%20%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20Get-Recipient%20-Identity%20%24member.Name%20%7C%20select%20PrimarySmtpAddress%20%7CFormat-Wide%20%0A%20%20%20%20%7D%0A%20%20%20%20%20%0A%7D” message=”” highlight=”” provider=”manual”/]

Nutanix N-able Service Template

 [pastacode lang=”markdown” user=”pariswells” repos=”public-code” path_id=”Nutanix%20Cluster.xml” revision=”” highlight=”” lines=”” provider=”github”/] [pastacode lang=”markdown” user=”pariswells” repos=”public-code” path_id=”Nutanix Console.xml” revision=”” highlight=”” lines=”” provider=”github”/] [pastacode lang=”markdown” user=”pariswells” repos=”public-code” path_id=”Nutanix Controller.xml” revision=”” highlight=”” lines=”” provider=”github”/] [pastacode […]

How to List Folder Permissions for User Shares and Reset the NTFS permissions

List the permissions on all the folders[pastacode lang=”markdown” user=”pariswells” repos=”public-code” path_id=”ListFolderPermission.ps1″ revision=”” highlight=”” lines=”” provider=”github”/]Change the permissions[pastacode lang=”markdown” user=”pariswells” repos=”public-code” path_id=”FixUserFolderNTFSPermissions.ps1″ revision=”” highlight=”” lines=”” provider=”github”/]