How to list out disk-info?

-1

Edited after some development.

I'm trying to make a script that finds all computers in an Organizational Unit (in Active Directory), and lists out size of the drive and amount of free space available.

This is what I got now:

$ou = Get-ADOrganizationalUnit -Properties * -Identity 'ou=Brukere,DC=GGR11,DC=local'

$RemServer = "xxx.xxx.xxx.xxx" #AD IP
$s = new-pssession -computer $RemServer -Credential GGR11.local\administrator #Credential = navn på domenet\domene administrator

$computers = Invoke-Command -Session $s -ScriptBlock {Get-ADComputer -Filter * -Properties name } -ArgumentList $ou

foreach ($i in $computers){
    #Finner diskbruk for en maskinen
    $disk = Get-WmiObject Win32_LogicalDisk -ComputerName $i -Filter "DeviceID='C:'" |Select-Object Size,FreeSpace

    $disk.Size / 1GB
    $disk.FreeSpace / 1GB
} 

This gives me an error:

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

The firewall on both the server and client is down, and i can share files between the two. DCOM is enabled on both server and target PC.

Default Authntication level: Connect

Default Impersonation level: Identify

The questions:

  1. Can anyone please look over the script? Is there something I have done wrong?
  2. What can I do to get rid of the error?
powershell
active-directory
wmi
diskspace
asked on Stack Overflow Sep 7, 2015 by damnnickname • edited Sep 8, 2015 by Ansgar Wiechers

1 Answer

0

Quoting from the WMI Troubleshooting Guide:

Error                     Possible Issues              Solution

0x800706BA - RPC Server   The computer really doesn't  Connecting to Vista: netsh
Unavailable               exist                        advfirewall firewall set
                          The Windows Firewall is      rule group="windows
Firewall issue or server  blocking the connection      management instrumentation
not available.                                         (wmi)" new enable=yes
                                                       Connecting to downlevel:
                                                       Allow the "Remote
                                                       Administration" rule in
                                                       Windows Firewall. 

So, check which host $i is causing the error and double-check that the host is actually running and that the Windows Firewall is either disabled or has the abovementioned exceptions configured. Check if you can connect to Port 135/tcp on the remote host, for instance with telnet

telnet a.b.c.d 135
answered on Stack Overflow Sep 8, 2015 by Ansgar Wiechers

User contributions licensed under CC BY-SA 3.0