Forum Widgets
Latest Discussions
DNS lookup performance
Hello all I've got this to do what I want but thought I'd run it past people who know more than me in the hope someone would be kind enough to advise on the following. The intention is to run this every few minutes using task scheduler, I'll push to one or more machines with an RMM. Questions. Is this an efficient an accurate way to do this? Are there any improvements anyone wants to suggest for the code Am I re-inventing a wheel that I can get somewhere for free or low cost? I'm waiting for the new version of GRC's DNS testing tool so this is a stopgap unless it works well enough. TIA # Define an array to store the DNS Servers to be queried with thier FQDN and IP address $dnsServers = @() # Add 5 hosts with their FQDN and IP addresses $dnsServers += [PSCustomObject]@{ FQDN = "OurDNS1"; IPAddress = "14.15.16.17" } $dnsServers += [PSCustomObject]@{ FQDN = "OurDNS2"; IPAddress = "11.12.13.14" } $dnsServers += [PSCustomObject]@{ FQDN = "Cloudflare"; IPAddress = "1.1.1.1" } $dnsServers += [PSCustomObject]@{ FQDN = "Quad9"; IPAddress = "9.9.9.9" } $dnsServers += [PSCustomObject]@{ FQDN = "Google"; IPAddress = "8.8.8.4" } # Define an array to store target FQDNs $targetFqdns = @( "bbc.co.uk", "www.porsche.com", "www.amazon.co.uk" ) # Get the current date in yyyy-MM-dd format $currentDate = Get-Date -Format "yyyy-MM-dd" # Define the path to the CSV file with the current date in the filename $filePath = "$PSScriptRoot\DNSResults_$currentDate.csv" # Initialize the CSV file with headers if it doesn't exist if (-not (Test-Path $filePath)) { "Timestamp,Milliseconds,TargetURL,DNSServerIP,DNSServer" | Out-File -FilePath $filePath } # Loop through each target host and then each DNS server foreach ($targetFqdn in $targetFqdns) { foreach ($dnsServer in $dnsServers) { # Measure the time taken to run the command $measure = Measure-Command -Expression { nslookup $targetFqdn $dnsServer > $null 2>&1 } # Get the current date and time in ISO 8601 format $timestamp = Get-Date -Format "yyyy-MM-ddTHH:mm:ss" # Get the total milliseconds and round up to a whole number $milliseconds = [math]::Ceiling($measure.TotalMilliseconds) # Append the timestamp, milliseconds, domain, server, and name to the CSV file $result = "$timestamp,$milliseconds,$targetFqdn," $dnsServerUSed = "$($dnsServer.IPAddress),$($dnsServer.FQDN)" $output = $result + $dnsServerUsed $output | Out-File -FilePath $filePath -Append } }ProcradminatorFeb 12, 2025Copper Contributor9Views0likes0CommentsAutomate Powershell Force OneDrive to Re Sync if there is a Sync Error noted
we use an RMM to automate powershell scripts to workdevices to monitor them. We get a lot of "OneDrive for Business, error with syncing" alerts. What I always see is that if OneDrive is restarted (manually) the sync is done again and the error is solved. Do people have a powershell script to "re sync", a script that we can initialize when an alert like this is coming up. So we don't have to manually restart or reïnstall onedrive to solve itOlivierKipLucrasoftFeb 12, 2025Occasional Reader3Views0likes0CommentsWhere can I find a lots of scripts like Script Guy site used to have?
Hi, I am sorry if this is a bit of easy post but the internet appears to be so spread out these days and de-centralised from what it used to be. I am looking for a site that has lots of good scripts similar to the good old Script Guy site. Please can you help. ThanksmidimanFeb 11, 2025Copper Contributor1.7KViews1like2CommentsHow to find out the type of a generic class?
Exmple: create a new List<string> instance: $a = [System.Collections.Generic.List[string]]::new() With: $a.GetType() I only get: IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True List`1 System.Object How can I tell what type the list is (in my case, string)?SolvedahinterlFeb 11, 2025Brass Contributor12Views0likes2CommentsGet-MpComputerStatus returns no output
Hello, on a Server 2019 with windows defender installed in the "Windows Security GUI" all is fine. Protection definitions are up to date, exclusions are set ... (managed with SCCM) But when i use the Get-MpComputerStatus it returns no output. (not even an error) Please help.blindpepperFeb 10, 2025Copper Contributor22KViews2likes17CommentsI want to create Sharepoint Verisoning Report on my Tenant
I have created a script, but dont seem to be able to find out how many file versions there are , Config Variables $TenantAdminURL = "https://admin.sharepoint.com" $CSVFilePath = "C:\Temp\RESTART.csv" #Get the Root Web #$Web = Get-PnpWeb #$versions = Get-SPOListItemVersion -ListItem $listItem #Get the Site Title Write-host -f Green $Web.Title #Connect to Admin Center using PnP Online Connect-PnPOnline -Url $TenantAdminURL -ClientId “cabf4-cc9b-4dcf-807b-8af94c3c4333" -Interactive -ForceAuthentication #Delete the Output Report, if exists if (Test-Path $CSVFilePath) { Remove-Item $CSVFilePath } #Get All Site collections - Exclude: Seach Center, Redirect site, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites $SiteCollections = Get-PnPTenantSite | Where { $.URL -like '/sites' -and $.Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")} #Get All Large Lists from the Web - Exclude Hidden and certain lists $ExcludedLists = @("Form Templates","Site Assets", "Pages", "Site Pages", "Images", "Site Collection Documents", "Site Collection Images","Style Library") $SiteCounter = 1 #Loop through each site collection ForEach($Site in $SiteCollections) { #Display a Progress bar Write-Progress -id 1 -Activity "Processing Site Collections" -Status "Processing Site: $($Site.URL)' ($SiteCounter of $($SiteCollections.Count))" -PercentComplete (($SiteCounter / $SiteCollections.Count) * 100) #Connect to the site Connect-PnPOnline -Url $Site.URL -Interactive #Get all document libraries $DocumentLibraries = Get-PnPList | Where-Object {$_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $False -and $_.Title -notin $ExcludedLists -and $_.ItemCount -gt 0} $ListCounter = 1 $ItemsColl = $List2.Items #Iterate through document libraries ForEach ($List in $DocumentLibraries) { $global:counter = 0 $FileData = @() Write-Progress -id 2 -ParentId 1 -Activity "Processing Document Libraries" -Status "Processing Document Library: $($List.Title)' ($ListCounter of $($DocumentLibraries.Count))" -PercentComplete (($ListCounter / $DocumentLibraries.Count) * 10) #Get All Files of the library with size > 100MB $Files = Get-PnPListItem -List $List -Fields FileLeafRef,FileRef,SMTotalFileStreamSize -PageSize 500 -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -Id 3 -parentId 2 -PercentComplete ($global:Counter / ($List.ItemCount) * 10) -Activity "Getting List Items of '$($List.Title)'" -Status "Processing Items $global:Counter to $($List.ItemCount)";} | Where {($_.FileSystemObjectType -eq "File") -and ($_.FieldValues.SMTotalFileStreamSize/1MB -gt 100)} #Collect data from each files ForEach ($File in $Files) { $FileData += [PSCustomObject][ordered]@{ Site = $Web.url Library = $List.Title FileName = $File.FieldValues.FileLeafRef URL = $File.FieldValues.FileRef Size = [math]::Round(($File.FieldValues.SMTotalFileStreamSize/1MB),2) } } #Export Files data to CSV File $FileData | Sort-object Size -Descending $FileData | Export-Csv -Path $CSVFilePath -NoTypeInformation -Append $ListCounter++ #Write-Progress -Activity "Completed Processing List $($List.Title)" -Completed -id 2 } $SiteCounter++ }NightWing2099Feb 06, 2025Copper Contributor8Views0likes0CommentsSearch-UnifiedAuditLog limitation on number of results
Hi, I need to extract PowerBI audit logs in order to get some valuable information. So, I'm using Search-UnifiedAuditLog command, which according to the documentation could parse 50.000 records. But in fact using the switch "-SessionCommand ReturnLargeSet" still returns 100 records. If I use the switch "-ResultSize 5000" then I can get 5.000 records. But I've made that search on the compliance portal and I've got about 110k results. So how can I get this 110k results via the Search-UnifiedAuditLog command? Anyone faced a similar issue? Documentation link: https://learn.microsoft.com/en-us/powershell/module/exchange/search-unifiedauditlog?view=exchange-ps ThanksSolveddmarquesgnFeb 05, 2025Iron Contributor3.7KViews0likes8CommentsError PowerShell 30015-1015 (80)
Hello, using P.Shell for office installation, with ODT, it gives me the following error shown in the photo, or opening the console in any folder with the right mouse button "open the P.S. window here" gives an error: Missing termination character in the string: ". + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString or Set-Location : Impossibile trovare un parametro posizionale che accetta l'argomento 'Ripristino\Office\Office'. In riga:1 car:1 + Set-Location -literalPath D:\Ripristino\File Ripristino\Office\Office ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand While if I run the command on the desktop, the window opens normally! ThanksAlpha45Feb 05, 2025Brass Contributor21Views0likes1CommentError PowerShell 30015-1015 (80)
Hello, using PowerShell for office installation, with ODT, it gives me the following error shown in the photo, or opening the console in any folder with the right mouse button "open the P.S. window here" gives an error: Missing termination character in the string: ". + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString Or Set-Location : Impossibile trovare un parametro posizionale che accetta l'argomento 'Ripristino\Office\Office'. In riga:1 car:1 + Set-Location -literalPath D:\Ripristino\File Ripristino\Office\Office ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand While if I run the command on the desktop, the window opens normally! ThanksAlpha45Feb 05, 2025Brass Contributor8Views0likes0CommentsError PowerShell 300-1015 (80)
Hello, using PowerShell for office installation, with ODT, it gives me the following error shown in the photo, or opening the console in any folder with the right mouse button "open the P.S. window here" gives an error: Missing termination character in the string: ". + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString or While if I run the command on the desktop, the window opens normally! Thanks Set-Location : Impossibile trovare un parametro posizionale che accetta l'argomento 'Ripristino\Office\Office'. In riga:1 car:1 + Set-Location -literalPath D:\Ripristino\File Ripristino\Office\Office ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommandAlpha45Feb 05, 2025Brass Contributor5Views0likes0Comments
Resources
Tags
- Windows PowerShell1,152 Topics
- powershell335 Topics
- office 365270 Topics
- azure active directory137 Topics
- Windows Server127 Topics
- sharepoint127 Topics
- windows97 Topics
- azure94 Topics
- exchange88 Topics
- Community54 Topics