Forum Widgets
Latest Discussions
positioning a set of powershell windows
Greetings, I'm completely new to this area. I have a requirement to display 3 separate powershell windows that are created from nodejs on my server, in essentially this format, ------- ---------------------------- | 1 | | 2 | ------- ----------------------------- ------------------------------------- | 3 | -------------------------------------- is the monitoring server app is the adminController app is the mainServerHub for all client connections to main app. is started manually on the server and automatically positions itself on the screen is created by the monitoring server app (1) and should be positioned on the right of screen 1 is also created by the monitoring server app (1) and should be positioned under both 1 and 2 I have searched many descriptions and links to resolve this challenge. I'm successful in creating all of the powershell windows from nodejs, but it has quite a challenge trying to manipulate their positions, and I'm looking for the appropriate cmdlets to accomplish this task. Can anyone point me in the right direction? Thanks Scott.sjn001tvhJan 24, 2025Copper Contributor16Views0likes1CommentNew-MgBookingBusinessService CustomQuestions
Hi! I'm working my way though BookingBusiness with PowerShell, so please forgive me if this is obvious. I've tried combing documentation but nothing seems to work. I have this script, and first, I think I have to create the customQuestions and have done so successfully and have the reference IDs for the questions to use in the New-MgBookingBusinessService script. I cannot seem to get the customQuestion piece to work. I'm first getting the available business staff and the custom questions I've already created. Everything works until I try the CustomQuestions piece. Here is what I have if you could please provide any assistance or guidance. Thank you! # Define the Booking Business ID $bookingBusinessId = "SCRUBBED" # Path to your CSV file $csvFilePath = "SCRUBBED" # Import CSV file $staffEmails = Import-Csv -Path $csvFilePath # Retrieve all staff members for the booking business Write-Host "Fetching all staff members for booking business ID: $bookingBusinessId" $allStaff = Get-MgBookingBusinessStaffMember -BookingBusinessId $bookingBusinessId # Ensure $allStaff is not null or empty if (-not $allStaff) { Write-Error "No staff members found for the booking business ID: $bookingBusinessId" return } # Debugging: Display all staff members retrieved (with Email and ID) Write-Host "Staff members retrieved (Email and ID):" -ForegroundColor Green $allStaff | ForEach-Object { $email = $_.AdditionalProperties["emailAddress"] $id = $_.Id $displayName = $_.AdditionalProperties["displayName"] Write-Host "DisplayName: $displayName, Email: $email, ID: $id" -ForegroundColor Yellow } # Retrieve all custom questions for the booking business Write-Host "Fetching all custom questions for booking business ID: $bookingBusinessId" $allCustomQuestions = Get-MgBookingBusinessCustomQuestion -BookingBusinessId $bookingBusinessId # Ensure $allCustomQuestions is not null or empty if (-not $allCustomQuestions) { Write-Error "No custom questions found for the booking business ID: $bookingBusinessId" return } # Debugging: Display all custom questions retrieved (with ID and DisplayName) Write-Host "Custom questions retrieved (ID and DisplayName):" -ForegroundColor Green $allCustomQuestions | ForEach-Object { $id = $_.Id $displayName = $_.DisplayName Write-Host "ID: $id, DisplayName: $displayName" -ForegroundColor Yellow } # Loop through each staff member in the CSV and create an individual service for them Write-Host "Creating individual booking services for each staff member..." $staffEmails | ForEach-Object { $email = $_.staffemail.Trim().ToLower() # Find the matching staff member by email $matchingStaff = $allStaff | Where-Object { $_.AdditionalProperties["emailAddress"] -and ($_.AdditionalProperties["emailAddress"].Trim().ToLower() -eq $email) } if ($matchingStaff) { $staffId = $matchingStaff.Id Write-Host "Match found: Email: $email -> ID: $staffId" -ForegroundColor Cyan # Create the booking service for the matched staff member try { $serviceParams = @{ BookingBusinessId = $bookingBusinessId DisplayName = "$($matchingStaff.AdditionalProperties["displayName"]) Family Conference" StaffMemberIds = @($staffId) # Create a service only for this staff member DefaultDuration = [TimeSpan]::FromHours(1) DefaultPrice = 50.00 DefaultPriceType = "free" Notes = "Please arrive 10 minutes early for your booking." CustomQuestions = $allCustomQuestions | ForEach-Object { @{ Id = $_.Id IsRequired = $true # or $false depending on your requirement } } } # Log the parameters being sent Write-Host "Service Parameters for $($matchingStaff.AdditionalProperties["displayName"]):" -ForegroundColor Blue $serviceParams.GetEnumerator() | ForEach-Object { Write-Host "$($_.Key): $($_.Value)" } New-MgBookingBusinessService @serviceParams Write-Host "Booking service successfully created for $($matchingStaff.AdditionalProperties["displayName"])!" -ForegroundColor Green } catch { Write-Error "Failed to create booking service for $($matchingStaff.AdditionalProperties["displayName"]): $_" } } else { Write-Warning "No match found for email: $email" } }AP_TC_ECASDJan 23, 2025Copper Contributor2Views0likes0CommentsExternal Access Policy - CsExternalAccessPolicy e CsTenantFederationConfiguration (PowerShell)
Hello, community. We are trying to enable functionality regarding the creation of external access policies using the New-CsExternalAccessPolicy (CommunicationWithExternalOrgs) and Set-CsTenantFederationConfiguration (CustomizeFederation) commands. However, we are receiving the following error: Set-CsTenantFederationConfiguration : Customize Federation is not allowed to enable in your tenant. In line:1 character:1 + Set-CsTenantFederationConfiguration -CustomizeFederation $true + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ({ ConfigType = ...Configuration }:<>f__AnonymousType104`5) [Set-CsTenantFederationConfiguration], Exception + FullyQualifiedErrorId : ClientError,Microsoft.Teams.ConfigApi.Cmdlets.SetCsTenantFederationConfiguration Is it necessary to do something first? We are following the documentation below: https://learn.microsoft.com/en-us/microsoftteams/trusted-organizations-external-meetings-chat?tabs=organization-settings TKS!rrdrummond88Jan 22, 2025Copper Contributor17Views0likes1CommentGet a list of specific agegroup users stored on a security group
Dear Community, I wonder if it would be possible to get a list of users (stored in a security group) marked as "minor" and "not adult" using microsoft graph. Once I get the members of the group (using Get-MgGroupMember -GroupId XXXX), I am not sure how to retrieve only the ones with a specific agegroup property. Is that feasible? Any help would be greatly appreciated. Many thanks in advance!Solved33Views0likes2CommentsPowerShell 7.4 SharePoint Question
Hi everyone, I’m seeking assistance with constructing a PowerShell script to manage document versions and space on multiple SharePoint sites. My goal is to: Connect to various SharePoint sites. Delete older copies of documents to free up space. Update version history settings to ensure future document control. Pull the list of SharePoint sites from a CSV file to handle multiple sites at once. Produce a log at the end of the script execution. I’ve encountered challenges with consistent authentication methods, having tried PnP PowerShell and SharePoint REST API. I would appreciate guidance on the best approach for handling credentials and login within the script. Any advice or examples would be greatly appreciated! Thank you in advance for your help.MatthewLottsJan 22, 2025Copper Contributor12Views0likes1CommentHow to remove Google Meet links and add Teams links in all recently migrated calendar events?
Hello, we have just finished migrating our company from Google Workspace to O365. Things went more or less smoothly, but now we're noticing that all of our migrated calendar events still have the Google Meet link associated with them. Is there a way to bulk remove all Google Meet links from all of our calendar items and replace them with Teams links? Many thanks in advance!VojtechBJan 22, 2025Copper Contributor13Views0likes1Commentfind the azure vm status in multiple subscription
We have multiple subscription (more than 10) in our environment and MFA enabled , I was trying to find one vm status using the name but its not working , setting azcontext with tenant ID also not working , I need command to set all subscription as context and find the vm status or any other way to find the vm status , this is needed for daily work, appreciate someone help on this .Sean145Jan 22, 2025Copper Contributor9Views0likes1CommentWebView2 HTML parsing
The code below embeds a web-scraping test URI into a Webview2 control. The button2 function returns the links for the site, but requires a redundant Invoke-WebRequest. I know Webview2 does not have an internal DOM capability and the $htmlContent = $WebView2.ExecuteScriptAsync() to return HTML is commented out as it does not appear to work. Is there a way to obtain the html without the Invoke-WebRequest()? function button1 { $title = 'Enter New URL to Navigate To' $msg = 'Please enter URL as https://[...some site...].com/.net/.org' $url = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title) $url if ($url -ne "") { try { $WebView2.Source = $url $WebView2.Refresh() } catch { $pop.popup("Invalid or Unuseable URL",2,"Error",4096) } } } function button2 { $links = ( Invoke-WebRequest -Uri $WebView2.Source).Links.Href | Get-Unique $regex = '/product*' $links | Select-String $regex | Select line | Out-Gridview -Title "Webpage Links for Products" -PassThru #$pop.popup("Code for Scraping Links",2,"Message",4096) } ######################################################################################################################## $pop = New-Object -ComObject wscript.shell New-Variable -Name 'data' -Value "$([Environment]::GetEnvironmentVariable('LOCALAPPDATA'))\Webview2" -Scope Global -Force $path=$PSScriptRoot # Get DLLs $WinForms = "$path\Microsoft.Web.WebView2.WinForms.dll" $Core = "$path\Microsoft.Web.WebView2.Core.dll" <# $loader = "$path\WebView2Loader.dll" $wpf = "$path\Microsoft.Web.WebView2.Wpf.dll" #> Add-Type -AssemblyName Microsoft.VisualBasic Add-Type -Path $WinForms #Add-Type -Path $Core Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $Form = New-Object System.Windows.Forms.Form $button1 = New-Object System.Windows.Forms.Button $button2 = New-Object System.Windows.Forms.Button $cancelButton = New-Object System.Windows.Forms.Button # $button1.Location = New-Object System.Drawing.Point(23, 25) $button1.Name = "button1" $button1.Size = New-Object System.Drawing.Size(75, 23) $button1.TabIndex = 0 $button1.Text = "New URL" $button1.BackColor = "Green" $button1.ForeColor = "White" $button1.AutoSize = $true # $button2.Location = New-Object System.Drawing.Point(312, 25) $button2.Name = "button2" $button2.Size = New-Object System.Drawing.Size(75, 23) $button2.TabIndex = 1 $button2.Text = "Links" $button2.BackColor = "Green" $button2.ForeColor = "White" $button2.AutoSize = $true # $cancelButton.Location = New-Object System.Drawing.Point(684, 25) $cancelButton.Name = "button3" $cancelButton.Size = New-Object System.Drawing.Size(75, 23) $cancelButton.TabIndex = 2 $cancelButton.Text = "Close" $cancelButton.BackColor = "Red" $cancelButton.ForeColor = "White" $cancelButton.Text = 'Close Window' $cancelButton.AutoSize = $true $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $Form.CancelButton = $cancelButton # $WebView2 = New-Object -TypeName Microsoft.Web.WebView2.WinForms.WebView2 $WebView2.CreationProperties = New-Object -TypeName 'Microsoft.Web.WebView2.WinForms.CoreWebView2CreationProperties' $WebView2.CreationProperties.UserDataFolder = $data #keeps it out of $PSScriptRoot $WebView2.Source = "https://www.scrapingcourse.com/ecommerce/" $Webview2.Location = New-Object System.Drawing.Point(23, 65) $Webview2.Size = New-Object System.Drawing.Size(749, 373) $WebView2.Anchor = 'top,right,bottom,left' <#navigation complete $WebView2_NavigationCompleted = { $htmlContent = $WebView2.ExecuteScriptAsync("window.chrome.webview.postMessage(document.documentElement.outerHTML;").Result #$htmlContent = $webView2.CoreWebView2.ExecuteScriptAsync("document.documentElement.outerHTML;").Result Write-Host $htmlContent } $WebView2.add_NavigationCompleted($WebView2_NavigationCompleted) $WebView2.add_WebMessageReceived({ param($WebView2, $message) $pop.popup($message.TryGetWebMessageAsString(),3,"Message",4096) }) #> $Form.ClientSize = New-Object System.Drawing.Size(800, 450) $Form.Controls.Add($Webview2) $Form.Controls.Add($cancelButton) $Form.Controls.Add($button2) $Form.Controls.Add($button1) $Form.Name = "Form" $Form.Text = "Webview Web Scraping Sample" $button1.add_click( { button1 }) $button2.add_click( { button2 }) $result=$Form.ShowDialog() #Terminate if Cancel button pressed if ($result -eq [System.Windows.Forms.DialogResult]::Cancel) { [System.GC]::Collect() [System.GC]::WaitForPendingFinalizers() $form.Dispose() Exit } ########################################################################################################################StanLJan 20, 2025Copper Contributor10Views0likes0CommentsWebView2 HTML web-scraping
Interested in a Powershell winform embedding a Webview2 control but with web-scraping capability. Initial frustration trying to find a Microsoft.Web.WebView2.WinForms.dll file that would load in a script w/out error. Downloaded Nuget package(s) which failed, then realized I had about 20 copies of the dll on my PC, most with different dates/sizes associated with different apps/folders. I finally found a file with size of 40,880 (copied from PowerBI \bin) which worked when copied to the PS script working folder. The script below works with that dll file. It navigates to a test webscrape site. In addition to a close button, I added buttons to navigate to another url or display links for the currently displayed URL. The issue is the links button has to perform an Invoke-Webrequest to the site which is redundant since the site is already loaded in the Webview. I realize Webview2 has no internal DOM parsing, but the HTML should be available for parsing. In the script code there is a commented section for using $WebView2.ExecuteScriptAsync() to obtain the HTML. No matter I have tried to use that it doesn't work. Long story short: is there a way to obtain/parse WebView2 HTML in a winform w/out having to redundantly perform Invoke-Webrequest. ################ Script ################################################ function button1 { $title = 'Enter New URL to Navigate To' $msg = 'Please enter URL as https://[...some site...].com/.net/.org' $url = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title) $url if ($url -ne "") { try { $WebView2.Source = $url $WebView2.Refresh() } catch { $pop.popup("Invalid or Unuseable URL",2,"Error",4096) } } } function button2 { $links = ( Invoke-WebRequest -Uri $WebView2.Source).Links.Href | Get-Unique $regex = '/product*' $links | Select-String $regex | Select line | Out-Gridview -Title "Webpage Links for Products" -PassThru #$pop.popup("Code for Scraping Links",2,"Message",4096) } ######################################################################################################################## $pop = New-Object -ComObject wscript.shell New-Variable -Name 'data' -Value "$([Environment]::GetEnvironmentVariable('LOCALAPPDATA'))\Webview2" -Scope Global -Force $path=$PSScriptRoot # Get DLLs $WinForms = "$path\Microsoft.Web.WebView2.WinForms.dll" $Core = "$path\Microsoft.Web.WebView2.Core.dll" <# $loader = "$path\WebView2Loader.dll" $wpf = "$path\Microsoft.Web.WebView2.Wpf.dll" #> Add-Type -AssemblyName Microsoft.VisualBasic Add-Type -Path $WinForms #Add-Type -Path $Core Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $Form = New-Object System.Windows.Forms.Form $button1 = New-Object System.Windows.Forms.Button $button2 = New-Object System.Windows.Forms.Button $cancelButton = New-Object System.Windows.Forms.Button # $button1.Location = New-Object System.Drawing.Point(23, 25) $button1.Name = "button1" $button1.Size = New-Object System.Drawing.Size(75, 23) $button1.TabIndex = 0 $button1.Text = "New URL" $button1.BackColor = "Green" $button1.ForeColor = "White" $button1.AutoSize = $true # $button2.Location = New-Object System.Drawing.Point(312, 25) $button2.Name = "button2" $button2.Size = New-Object System.Drawing.Size(75, 23) $button2.TabIndex = 1 $button2.Text = "Links" $button2.BackColor = "Green" $button2.ForeColor = "White" $button2.AutoSize = $true # $cancelButton.Location = New-Object System.Drawing.Point(684, 25) $cancelButton.Name = "button3" $cancelButton.Size = New-Object System.Drawing.Size(75, 23) $cancelButton.TabIndex = 2 $cancelButton.Text = "Close" $cancelButton.BackColor = "Red" $cancelButton.ForeColor = "White" $cancelButton.Text = 'Close Window' $cancelButton.AutoSize = $true $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $Form.CancelButton = $cancelButton # $WebView2 = New-Object -TypeName Microsoft.Web.WebView2.WinForms.WebView2 $WebView2.CreationProperties = New-Object -TypeName 'Microsoft.Web.WebView2.WinForms.CoreWebView2CreationProperties' $WebView2.CreationProperties.UserDataFolder = $data #keeps it out of $PSScriptRoot $WebView2.Source = "https://www.scrapingcourse.com/ecommerce/" $Webview2.Location = New-Object System.Drawing.Point(23, 65) $Webview2.Size = New-Object System.Drawing.Size(749, 373) $WebView2.Anchor = 'top,right,bottom,left' <#navigation complete $WebView2_NavigationCompleted = { $htmlContent = $WebView2.ExecuteScriptAsync("window.chrome.webview.postMessage(document.documentElement.outerHTML;").Result #$htmlContent = $webView2.CoreWebView2.ExecuteScriptAsync("document.documentElement.outerHTML;").Result Write-Host $htmlContent } $WebView2.add_NavigationCompleted($WebView2_NavigationCompleted) $WebView2.add_WebMessageReceived({ param($WebView2, $message) $pop.popup($message.TryGetWebMessageAsString(),3,"Message",4096) }) #> $Form.ClientSize = New-Object System.Drawing.Size(800, 450) $Form.Controls.Add($Webview2) $Form.Controls.Add($cancelButton) $Form.Controls.Add($button2) $Form.Controls.Add($button1) $Form.Name = "Form" $Form.Text = "Webview Web Scraping Sample" $button1.add_click( { button1 }) $button2.add_click( { button2 }) $result=$Form.ShowDialog() #Terminate if Cancel button pressed if ($result -eq [System.Windows.Forms.DialogResult]::Cancel) { [System.GC]::Collect() [System.GC]::WaitForPendingFinalizers() $form.Dispose() Exit } ########################################################################################################################StanLJan 19, 2025Copper Contributor12Views0likes0Comments
Resources
Tags
- Windows PowerShell1,140 Topics
- powershell335 Topics
- office 365270 Topics
- azure active directory137 Topics
- Windows Server127 Topics
- sharepoint125 Topics
- windows96 Topics
- azure93 Topics
- exchange87 Topics
- Community54 Topics