mount point report

sara2000
sara2000 used Ask the Experts™
on
I am looking for a powershell script to get report of mount points on few server.
Expert out there, Can you please share me he script?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2018

Commented:
Please try
Get-WmiObject Win32_Volume | ForEach {
    New-Object PSObject -Property @{
        Name = $_.Name
        Label = $_.Label
        FreeSpace_GB = ([Math]::Round($_.FreeSpace /1GB,2))
        TotalSize_GB = ([Math]::Round($_.Capacity /1GB,2))
    }
}

Open in new window

Author

Commented:
Thank you for this. IS there any way I can email the report .
Senior Consultant
Awarded 2017
Distinguished Expert 2018
Commented:
$smtpServer = "mailserver01"
$smtpFrom = "anotheraddress@mail.com"
$smtpTo = "someaddress@mail.com"
$messageSubject = "Subject"
 
$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true

$message.Body = Get-WmiObject Win32_Volume | ForEach { New-Object PSObject -Property @{ Name = $_.Name; Label = $_.Label; FreeSpace_GB = ([Math]::Round($_.FreeSpace /1GB,2)) TotalSize_GB = ([Math]::Round($_.Capacity /1GB,2)) }} | ConvertTo-Html

$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)

Open in new window

Author

Commented:
Thanks Shaun, I have no experience in scripts , hope you do not mind.  How do I run this remotely (from another server)?
Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2018

Commented:
No problem. Save in PS1 file and run
Invoke-Command -ComputerName ServerName01 -FilePath "C:\Temp\Script.ps1"

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial