• The final block of code should be more like the following. 

    Users might need to enable PSRemotting and have admin credentials to connect to the server/workstation.

    [CmdletBinding()]
    param(
    	[Parameter()]
    	[ValidateNotNullOrEmpty()]
    	[string[]]$Servers
    )
    
    foreach ($server in $servers) {
        $output = [ordered]@{
            'ServerName'         = $server
            'OperatingSystem'    = (Get-CimInstance -ComputerName $server -ClassName Win32_OperatingSystem).Caption
            'FreeDiskSpace (GB)' = [Math]::Round(((Get-CimInstance -ComputerName $server -ClassName Win32_LogicalDisk | Measure-Object -Property FreeSpace -Sum).Sum / 1GB),1)
            'Memory (GB)'        = (Get-CimInstance -ComputerName $server -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum /1GB
        }
        [pscustomobject]$output
    }
    0
  • You can use the following command in a batch file. The only need for this style of calling Powershell would be needed when using Powershell commands in conjunction with other batch commands...

    Just update the NAME_OF_FILE, the script will get the local path using the %~dp0 in-front of the filename.ps1.

    PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0NAME_OF_FILE.ps1""' -Verb RunAs}"
    1+
  • By creating GUIs with PowerShell in this manner, is it reliant on the .NET framework version a user is using?

    1+
  • You could add the items in the txt file as you did. Then you could put do a foreach loop for the files and run the QueryFileVersionsRemotely.ps1 file.

    $files = Get-Content C:pathtofiles.txt
    Foreach($line in $files){
    .QueryFileVersionsRemotely.ps1 -ComputerName (Get-Content D:TempComputerlist.txt) -Path $line -OutputFile C:TempFileVersionInfo.csv
    }

    The $line Variable should be the full path of the file. The trick is now to find a way to rename the output file to a different name for each file type.

    Or if the files are in the same directory you could pipe the command as well.

    ls | .QueryFileVersionsRemotely.ps1 -ComputerName (Get-Content D:TempComputerlist.txt) -Path "." -OutputFile C:TempFileVersionInfo.csv
    1+
  • Since you are saving the file as "WindowsProfiles.ps1" that will be what you need to call in the console. in the example above, the author saved the file as "Get-WindowsProfiles.ps1". That is why you are getting the error you stated.

    1+
  • The "VoicemailEnabled" would be your AD group you would change to your specific group you are needing to search within.

    1+
  • Clayton became a registered member 2 years, 9 months ago

    1+