User Profile
SteveCox
Brass Contributor
Joined Oct 11, 2021
User Widgets
Recent Discussions
Re: How to Find Active EWS-Based Apps in a Microsoft 365 Tenant
Hi TonyRedmond One thing I have noticed is inconstancy in the Report, I Ran it 3 Days ago and it found nothing in the last 7 Days, then Ran it again today and it found 10 Applications Using EWS on a Date that was within the Range of the 7 Days of the First Run of the Report. I am wondering if the data from this report can be relied upon? Kind Regards, Steve2KViews0likes1CommentRe: How to Find Active EWS-Based Apps in a Microsoft 365 Tenant
If you are struggling to find the App IDs it is easier in PowerShell using the following #Get Azure App Name from App ID Connect-MgGraph -Scopes Application.Read.All $appid = Read-Host "Enter App ID" Get-MgServicePrincipal -Filter "Appid eq '$appid'"1.5KViews0likes0CommentsRe: Setting Unified Group properties via API
Hi Tony, have just tested and ran the Following and this works now, if it is of any use to anyone this is the Full way that I have got Creating a Unified Group Using CBA working "#Connect to MS Graph Import-Module Microsoft.Graph.Authentication Connect-MgGraph -TenantId "Your Tennant ID" -AppId "Your App ID" -CertificateThumbprint "Your Cert Thumbprint" #Create Unified Group Via Graph Import-Module Microsoft.Graph.Groups $groupid = "Steve test automation2" $params = @{ Description = "External - Steve-test-automation2" DisplayName = "Steve test automation2" GroupTypes = @( "Unified" ) MailEnabled = $true MailNickname = "Steve-test-automation2" SecurityEnabled = $false } New-MgGroup -BodyParameter $params #Set Owner and Membership $Group = Get-MgGroup -Filter "DisplayName eq 'Steve test automation2'" $User = Get-MgUser -ConsistencyLevel eventual -Count userCount -Search "DisplayName:cox,steve" $MGGroupID = $Group.Id $MGUserID = $User.id $newGroupOwner =@{ "@odata.id"= "https://graph.microsoft.com/v1.0/users/{$MGUserID}" } New-MgGroupOwnerByRef -GroupId $MGGroupID -BodyParameter $newGroupOwner New-MgGroupMemberByRef -GroupId $MGGroupID -BodyParameter $newGroupOwner Disconnect-MgGraph #Connect to EXOL Import-Module ExchangeOnlineManagement Connect-ExchangeOnline -CertificateThumbPrint "Your Cert Thumbprint" -AppID "Your App ID" -Organization "Your Org.onmicrosoft.com" -UseRPSSession #Change unified Group Email Address Get-Group -Identity "Steve-test-automation2" |fl Set-Group -Identity "Steve-test-automation2" -WindowsEmailAddress "steve-test-automation2@yourOrg.com" #Set Allow External Senders Set-UnifiedGroup -Identity "Steve-test-automation2" -RequireSenderAuthenticationEnabled:$false Disconnect-ExchangeOnline3.7KViews0likes1CommentRe: Setting Unified Group properties via API
Hi Tony, I have found that I can change the Primary Email via Exchange-online Set-Group -Identity "Steve-test-automation2" -WindowsEmailAddress "steve-test-automation2@myorg.com" So All I need to do now is to Set the Unified Group to Allow External Senders, I cannot do this by Set-UnifiedGroup as this doesn't work with Certificate Based Authentication, and if I try adding AllowExternalSender = Strue to the New-MGGroup Params it gives an Error "New-MgGroup : The following properties cannot be set in the initial POST request. Please set them in a subsequent PATCH request: allowExternalSenders." how can I set this a PATCH Request from Powershell?3.9KViews0likes3CommentsRe: Setting Unified Group properties via API
Hi Tony Thanks for the info what I need is to be able to Set the Primary to company.co.uk instead of the Default company.onmicrosoft.com would be simple if I could just set this up using New-UnifiedGroup but doesn't work with CBA. Tried Setting it this way $groupid = "Steve test automation2" $params = @{ Description = "External - Steve-test-automation2" DisplayName = "Steve test automation2" GroupTypes = @( "Unified" ) MailEnabled = $true MailNickname = "Steve-test-automation2" Mail = "Email address removed" SecurityEnabled = $false } New-MgGroup -BodyParameter $params But it gives an error "New-MgGroup : Property 'mail' is read-only and cannot be set."3.8KViews0likes5CommentsRe: Setting Unified Group properties via API
Hi There I know this is an old thread but I am trying to create a Unified Group using Certificate based Authentication, I tried using ExchangeOnlineManagement Module, but apparently this doesn't work when you to use New-UnifiedGroup using CBA (Known Issue) so I tried using the Microsoft.Graph.Group Module using CBA to create the Unified Group, this created the Group, but I need to be able to Set the Primary Email address as well and cannot see a way to set this in the Microsoft.Graph.Group. Do you know if there is a way to Set this via MS.Graph ?3.9KViews0likes7CommentsRe: new content after last match of a Pattern in XML file
Hi yes thanks for the help worked perfectly, still had an issue with the Encoding of the XML output being Created as UTF-16 LE BOM so wouldn't Parse correctly so fixed this with this line to save a UTF-8 "[IO.File]::WriteAllLines($XMLPath, $BOMFile)" and also found that Defender doesn't Like Comments in the "Descriptor ID" so have removed them and created change log in a different Location So if anyone is trying to Use Scripts to Edit the XML Files for Defender USB Blocking watch out for Encoding and Comments Thanks again for the assistance1.4KViews0likes1Commentnew content after last match of a Pattern in XML file
Hi I am trying to use Powershell to add content to an XML file after the last match of a pattern I need to add the content from $OutTemp txt file "<!-- steve.cox - test3 -02/02/2022 11:01:36 --> <InstancePathId>USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_PMAP\5B8207000061&0</InstancePathId> <!-- steve.cox - test4 - -02/02/2022 11:01:36 --> <InstancePathId>USBSTOR\DISK&VEN_TOSHIBA&PROD_SILICON-POWER&REV_PMAP\MSFTNAKTM1070837BA061C1622&0</InstancePathId>" To below the last </InstancePathId> line of the USB-Groups.XML File <Groups> <Group Id="{9b28fae8-72f7-4267-a1a5-685f747a7146}"> <!-- ./Vendor/MSFT/Defender/Configuration/DeviceControl/PolicyGroups/%7b9b28fae8-72f7-4267-a1a5-685f747a7146%7d/GroupData --> <MatchType>MatchAny</MatchType> <DescriptorIdList> <PrimaryId>RemovableMediaDevices</PrimaryId> <PrimaryId>CdRomDevices</PrimaryId> <PrimaryId>WpdDevices</PrimaryId> </DescriptorIdList> </Group> <Group Id="{65fa649a-a111-4912-9294-fb6337a25038}"> <MatchType>MatchAny</MatchType> <DescriptorIdList> <InstancePathId>USBSTOR\DISK&VEN_TOSHIBA&PROD_SILICON-POWER&REV_PMAP\MSFTNAKTM10708466023196668&0</InstancePathId> <InstancePathId>USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_0000\408D5C1EF726102179650693&0</InstancePathId> <InstancePathId>USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_3.0&REV_PMAP\60A44C42651BB2A04626FC36&0</InstancePathId> <InstancePathId>USBSTOR\DISK&VEN_SANDISK&PROD_CRUZER_EDGE&REV_1.26\20043514001B91029E82&0</InstancePathId> </DescriptorIdList> </Group> </Groups>" If I use " Function WritetoXML { $NewLines = Get-Content -Path $OutTemp | ?{$_.Trim() -ne ""} $New = Get-Content -Path $XMLPath | ForEach-Object { $_ If($_-match ('</InstancePathId>')) { $NewLines } } $New | Out-File -FilePath $XMLPath -Force Remove-Item $OutTemp }" it writes after each instance of '</InstancePathId>' but cannot work out how to get this to write to only after the last instanceSolved1.5KViews0likes4CommentsRe: Automation of Exchange server Patching
Thanks got this to work for me by doing the below #Check that the HTML source was Created less that one hour ago function httpfiledate { $response2=Invoke-WebRequest "http://xxxxxxxx/edgestatus/" $response2.Headers.GetEnumerator() | ForEach { If($_.Key -eq "Last-Modified" ) { $_.value} $dateString={string]$_.value $dateObject= get-date $dateString } } } $filedate = httpfiledate $FileDateObj = get-date $filedate $hours = -1 $dif = (($FileDateObj) - (Get-Date).AddHours($hours)) if ($dif.Hours -ne 0) {Send-MailMessage -to $mailRecip -From $mailSender -Subject $mailSubject1 -BodyAsHtml -SmtpServer $mailServer -Body "HTTP File on Edge2 is over 1 hour old check Shed Task" ; Break } Else {Write-host "File OK"}4.2KViews1like0CommentsRe: Automation of Exchange server Patching
Just got one more question and then I can complete this bit of work and post it here. I need to get the last modified date from an Invoke-WebRequest $response = Invoke-WebRequest -uri http://xxxxxxx and if I look at $response I get the following output "PS C:\Windows\system32> $response1 StatusCode : 200 StatusDescription : OK Content : ÿþ< ! D O C T Y P E h t m l P U B L I C " - / / W 3 C / / D T D X H T M L 1 . 0 S t r i c t / / E N " " h t t p : / / w w w . w 3 . o r g / T R / x h t m l 1 / D T D / x h t m l 1 - s ... RawContent : HTTP/1.1 200 OK Accept-Ranges: bytes Content-Length: 2414 Content-Type: text/html Date: Thu, 04 Nov 2021 16:55:02 GMT ETag: "40fb6e89bd1d71:0" Last-Modified: Thu, 04 Nov 2021 16:49:17 GMT Serve... Forms : {} Headers : {[Accept-Ranges, bytes], [Content-Length, 2414], [Content-Type, text/html], [Date, Thu, 04 Nov 2021 16:55:02 GMT]...} Images : {} InputFields : {} Links : {} ParsedHtml : System.__ComObject RawContentLength : 2414" What I need is to get the Last-Modified date and check that this is todays date but cannot find a way to do this?4.3KViews0likes4CommentsRe: Automation of Exchange server Patching
Thanks that works perfectly now need to check cluster node Status so if I run "Get-ClusterNode -Name Exchange1 | FL State" I Get "State : Up" as an output but if I try "$cluster = Get-ClusterNode -Name Exchange1 | FL State If ($cluster.state -eq "Up") { Write-Host "Cluster is Up"} I get nothing4.6KViews0likes8CommentsAutomation of Exchange server Patching
Hi I am trying to setup a Script to automate patching of Exchange 2016 servers and I need to get the script to check if any if the other exchange server is in Maintenance Mode before continuing to place the first server into maintenance mode to allow me to install the updates and reboot the server. if I run the command "Get-databaseavailabilitygroup -status | fl ServersInMaintenance" it gives the result "ServersInMaintenance : {}" what I need to do it get a command to check that this result is this then continue but I cannot find anyway to interpret this result have tried $Maint = Get-databaseavailabilitygroup -status | fl ServersInMaintenance If ($Maint -contains {} ) { Write-Host "No Servers in Maintenace Mode"} But this doesn't work any help would be gratefully received4.8KViews0likes10Comments
Recent Blog Articles
No content to show