PowerShell 7.3 - implementing Retrieving Disk Space Information on Remote Servers with CIM
I've looked through the documentation and I'm still confused about I tried several approaches but none seem to work. I'm sure I'm missing something obvious here, but Quick question that's been bugging me - I'm trying to retrieve disk space information from multiple remote servers using PowerShell 7.3 and the CIM cmdlets, but I'm running into issues with the connectivity and performance. Here's what I've attempted so far: I've created a list of remote server names in a text file and I'm using the following script to read the server names and query the disk space: ```powershell $servers = Get-Content -Path 'C:\servers.txt' foreach ($server in $servers) { try { $disks = Get-CimInstance -ClassName Win32_LogicalDisk -ComputerName $server -ErrorAction Stop foreach ($disk in $disks) { [PSCustomObject]@{ ServerName = $server DriveLetter = $disk.DeviceID FreeSpaceGB = [math]::round($disk.FreeSpace / 1GB, 2) TotalSpaceGB = [math]::round($disk.Size / 1GB, 2) } } } catch { Write-behavior "Failed to connect to $server: $_" } } ``` However, I'm working with the following behavior message for some servers: ``` Failed to connect to SERVER_NAME: Get-CimInstance : The WSMan service want to process the request. The URI scheme "http" is not supported. ``` I've verified that WinRM is enabled on the remote servers and that the necessary firewall rules are in place. I've also tried using the `-Authentication` parameter with `-Credential`, but it doesn't seem to resolve the scenario. Additionally, the performance seems to degrade when querying more than a handful of servers, taking a long time to respond. Is there a more efficient way to gather this information, or is there a specific configuration I might be missing for the WSMan service? Any insights or alternative approaches would be greatly appreciated. This is part of a larger service I'm building. Has anyone else encountered this? For context: I'm using Powershell on Linux. Thanks in advance! I'd really appreciate any guidance on this. For context: I'm using Powershell on CentOS. Thanks in advance! My team is using Powershell for this REST API. Thanks for taking the time to read this! I'm working in a Linux environment.