Blog Stats
- 401,873 hits
-
Prashanth Jayaram
DB Technologist, Author, Blogger, Service Delivery Manager at CTS, Automation Expert, Technet WIKI Ninja, MVB and Powershell Geek My Profile: https://social.technet.microsoft.com/profile/prashanth jayaram/ http://www.sqlshack.com/author/prashanth/ http://codingsight.com/author/prashanthjayaram/ https://www.red-gate.com/simple-talk/author/prashanthjayaram/ http://www.sqlservercentral.com/blogs/powersql-by-prashanth-jayaram/ Connect Me: Twitter @prashantjayaram GMAIL powershellsql@gmail.com The articles are published in: http://www.ssas-info.com/analysis-services-articles/ http://db-pub.com/ http://www.sswug.org/sswugresearch/community/
Personal Links
Verified Services
Top 30 PowerShell bloggers of 2018
My Blog is ranked amongst the Top 50 SQL blogs worldwide
DZone MVB
Microsoft
Archives
- January 2021 (1)
- October 2020 (1)
- June 2019 (1)
- May 2019 (2)
- April 2019 (1)
- March 2019 (1)
- January 2019 (3)
- December 2018 (8)
- October 2018 (3)
- September 2018 (5)
- August 2018 (1)
- July 2018 (9)
- June 2018 (5)
- May 2018 (8)
- April 2018 (5)
- March 2018 (6)
- February 2018 (1)
- January 2018 (4)
- December 2017 (3)
- November 2017 (3)
- October 2017 (5)
- September 2017 (3)
- August 2017 (3)
- July 2017 (3)
- June 2017 (3)
- May 2017 (3)
- April 2017 (1)
- March 2017 (4)
- February 2017 (1)
- January 2017 (3)
- December 2016 (1)
- November 2016 (2)
- October 2016 (2)
- September 2016 (2)
- August 2016 (3)
- July 2016 (6)
- June 2016 (2)
- May 2016 (9)
- April 2016 (12)
- March 2016 (4)
- February 2016 (2)
- January 2016 (6)
- December 2015 (2)
- August 2015 (1)
- March 2015 (3)
- February 2015 (3)
- January 2015 (5)
- December 2014 (4)
- November 2014 (3)
- October 2014 (1)
- September 2014 (1)
- August 2014 (1)
- July 2014 (1)
- June 2014 (1)
- May 2014 (2)
- April 2014 (4)
- March 2014 (4)
- February 2014 (5)
- January 2014 (8)
- December 2013 (2)
- November 2013 (1)
- October 2013 (2)
- September 2013 (6)
- August 2013 (5)
- July 2013 (6)
- June 2013 (6)
- May 2013 (9)
- April 2013 (16)
Top Posts & Pages
- The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
- T-SQL - Read CSV files using OpenRowSet
- PowerShell- Monitoring Multiple Services On Multiple Servers Using Win
- PowerShell - Export SQL Data to Excel with Powershell
- T-SQL - How to find Next Business day from a given date
- Simple Methods to Recover master.mdf File Password
- PowerSQL - List SQL Server instance configuration details and sending an automated email
- Minimizing SQL Server DBCC CHECKDB Performance Impacts
- PowerShell - Find OS architecture (32 bit or 64 bit) of local or remote machines Using Powershell
- T-SQL - Query to get Distinct,Sorted, Comma Separated values in to a variable
Categories
- AlwaysOn (1)
- awards (2)
- Backup and Restore (14)
- Citrix (1)
- databases_files (2)
- docker (5)
- Exchange (2)
- FileProperty (1)
- GDPR (1)
- GENERAL (3)
- Graph database (1)
- JSON (4)
- Logshipping on Linux (1)
- MongoDB (16)
- NoSQL (1)
- Philosophy (1)
- PowerShell (64)
- Python (4)
- Robocopy (2)
- SCCM (1)
- Security (3)
- Vulnerability (1)
- SETVAR (2)
- sp_msforeachDB (1)
- sp_MSforeachtable (1)
- SQL (99)
- SQL 2012 (4)
- SQL 2016 (11)
- SQL 2017 (7)
- SQL 2017 on Linux (5)
- SQL and Python (1)
- SQL AZURE (2)
- SQL Indexes (1)
- SQL Joins (1)
- SQL On Linux (1)
- SQL Ops Studio (1)
- SQL Server 2017 (11)
- SQL Server Backup (10)
- SQL Server DevOps (1)
- SQL Server Tools (1)
- SQL Server vNext (2)
- SQL String (1)
- SQL tools (2)
- SQL XML (1)
- SQLCMD (3)
- SSAS (4)
- SSRS (3)
- String handling (2)
- sysfiles (3)
- T-SQL (37)
- Uncategorized (42)
- Variable Passing (1)
- XenApp VDA (1)
- XenDesktop VDA (1)
- XML (2)
- Follow Prashanth Jayaram on WordPress.com
- March 1, 2021The big day is here.
- The Big DayOctober 25, 2016The big day is here.
-
Recent Posts
- SQL PowerShell to check and repair Ad-hoc distributed queries Vulnerability January 4, 2021
- Hadoop Workflow Automation using Apache spark and Oozie October 30, 2020
- Import Local SQL Server Database to Azure – Pick the Best Method June 11, 2019
- Microsoft SQL Server Error 5243 – Top 3 Ways To Fix This Issue May 21, 2019
- Restore SQL Server 2014 Database from Backup – Step By Step Guide May 6, 2019
- Know How to Repair SQL Database Marked as Suspect Mode in SQL Server April 30, 2019
- Kernel Migrator for SQL Server – Expert Product Review March 17, 2019
- SQL Power Doc to Discover, Diagnose and Document SQL Server January 22, 2019
- Today, I’m making my 100th post on SQLShack January 14, 2019
- How to Change Suspect Mode to Normal Mode in SQL Server Database January 7, 2019
- Shrinking Tempdb in SQL Server won’t work? December 28, 2018
- Automation to list all TCP static and dynamic ports of SQL Server instances using PowerShell December 27, 2018
- Select-AzureRmProfile : The term ‘Select-AzureRmProfile’ is not recognized as the name of a cmdlet, function, script file, or operable program December 21, 2018
- Top 50 PowerShell bloggers of 2018 December 18, 2018
- How to automatically Discover SQL Server instances December 17, 2018
- SQL Server Essentials for beginners December 10, 2018
- SQL Date functions in SQL Server December 4, 2018
- Overview of DML Operations – SQL Delete December 3, 2018
- Overview of the SQL Insert statement October 26, 2018
- SQL Pivot and Unpivot relational operatots October 15, 2018
PowershellSQL
PowerShell : Monitoring and Notification – Disk Space Alerts
“Microsoft Technet Guru – Gold Medal Winning Article- Nov, 2016”
Abstract
Monitoring disk space utilization of server(s) is the critical and important job for any administrator. Keeping things organized might improve application availability and server availability. This article takes us through the in-detail steps to read each drive and notify every drive details based on threshold values and output data.You’ll basically feed a list of servers to watch over, and it will report back on these for you, meaning you could also use it as a more general “daily server disk space report”.A DBA doesn’t want to run out of space on their servers, even in their labs! To avoid this happening, wrote a PowerShell script to provide some alerts by email.
Table of Contents
Introduction
This article talks about the use of credentials. The credentials can be used to query external servers which have the trust relationship between the domains. Also, list various methods to secure the password. The process iterates through a list of servers and drives that you have listed in a csv file. Checking for disk space status of every listed drive and its status may fall under one of the four statuses that are defined as critical, warning, low and good. If the disk in a question of below the threshold then the corresponding status is updated and notification sent to the respective teams.
Highlights
Querying – Win32_LogicalDisks
Using Credentials
Get-Credential always pop-up dialog box for entering a password, however, you can save your securestring password to a file or directly feed the password. The problem with this is that the password will be exposed to anyone with access to the file.
Using Get-Credential cmdlet – Pop dialog box
The Get-Credential displays a window to enter credential details. This will appear every time when you run the script.The $credential variable store the username and password. It’s then fed to the respective queries for further processing.
clear
$credential = Get-Credential
foreach ( $args in get-Content c:\server.txt ) {
get-WmiObject win
32
_logicaldisk -Credential $credential -ComputerName $args -Filter
"Drivetype=3"
|
ft SystemName,DeviceID,VolumeName,@{Label=
"Total SIze"
;Expression={$_.Size /
1
gb -as [int] }},@{Label=
"Free Size"
;Expression={$_.freespace /
1
gb -as [int] }} -autosize
}
Hard code the credentials
The password is hard coded in the script. Of course, the problem with this is that your password will be exposed to anyone with access to the script file.
$User =
'hqnt\abcd'
$Pass = ConvertTo-SecureString
'abcd@2015'
-AsPlainText -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Pass
foreach ( $args in get-Content c:\server.txt ) {
get-WmiObject win
32
_logicaldisk -ComputerName $args -Credential $Credentials -Filter
"Drivetype=3"
|
ft SystemName,DeviceID,VolumeName,@{Label=
"Total SIze"
;Expression={$_.Size /
1
gb -as [int] }},@{Label=
"Free Size"
;Expression={$_.freespace /
1
gb -as [int] }} -autosize
}
Using Secured file
First, Password has to be written to a file
ps:\>read-host -AsSecureString |ConvertFrom-SecureString |Out-File C:\SecurePassword.txt
Second, The credentials are read from the file using PSCredential class. You don’t need to re-enter the password over and over again.
clear
$User =
'hqnt\abcdv'
$pass= cat C:\passwordstring.txt |ConvertTo-SecureString
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Pass
foreach ( $args in get-Content c:\server.txt ) {
get-WmiObject win
32
_logicaldisk -ComputerName $args -Credentials $cred -Filter
"Drivetype=3"
|
ft SystemName,DeviceID,VolumeName,@{Label=
"Total SIze"
;Expression={$_.Size /
1
gb -as [int] }},@{Label=
"Free Size"
;Expression={$_.freespace /
1
gb -as [int] }} -autosize
}
Without using Credentials
clear
foreach ( $args in get-Content c:\server.txt ) {
get-WmiObject win
32
_logicaldisk -ComputerName $args -Filter
"Drivetype=3"
|
ft SystemName,DeviceID,VolumeName,@{Label=
"Total SIze"
;Expression={$_.Size /
1
gb -as [int] }},@{Label=
"Free Size"
;Expression={$_.freespace /
1
gb -as [int] }} -autosize
}
Download
PowerShell : Monitoring and Notification – Disk Space Alerts
Code in detail
Input File
The template of Inputserver.csv is given below. Change the content as per your requirement/environment
import-csv C:\InputServer_
1
.csv |Format-Table -AutoSize
The comma-delimited text file (.csv) file InputServer_1.csv file is parsed below. You’ll notice at the top that there are headings for each column: ServerName, Drive, LowTh, WarnTh,CritTh,Email, LowPri, WarnPri, CritPri, and EscInst. The PowerShell import-csv cmdlet understands this default format and expects to see the column headers before parsing the main data.
The above columns are defined just to illustrate how the process works. This can vary for every environment by considering the underlying infrastructure
Write-Log
Write-Log writes a message to a specified log file along with the current time stamp also writes state of the message(Information, Warning or Error).
For example, The first example writes a simple message with a default state to a log file abc.log. In the second example, a message along with “Error” state details are entered into the log file.
1.
EXAMPLE
1
2.
PS:\> Write-Log -Message
"Server is reachable and starting the process "
-Logfile c:\PowerSQL\abc.log
3.
EXAMPLE
2
4.
PS:\> Write-Log -
level
Error -Message
"Server is not reachable "
-Logfile c:\PowerSQL\abc.log
The below function can be reused to in any of the PoSH code. Also, the output file will be used for troubleshooting and activity progress tracking.
01.
Function Write-Log {
02.
[CmdletBinding()]
03.
Param(
04.
[Parameter(Mandatory=$False)]
05.
[ValidateSet(
"INFO"
,
"WARN"
,
"ERROR"
)]
06.
[String]
07.
$Level =
"INFO"
,
08.
09.
[Parameter(Mandatory=$True)]
10.
[string]
11.
$Message,
12.
13.
[Parameter(Mandatory=$False)]
14.
[string]
15.
$logfile
16.
)
17.
18.
$Stamp = (Get-Date).toString(
"yyyy/MM/dd HH:mm:ss"
)
19.
$Line =
"$Stamp $Level $Message"
20.
If($logfile) {
21.
Add-Content $logfile -Value $Line
22.
}
23.
Else {
24.
Write-Output $Line
25.
}
26.
}
Password
This portion of code decides whether to pass credentials or not. The Get-credential always pop-up dialog box for entering a password, however, you can save your securestring password to a file or directly feed the password. The problem with this is that the password will be exposed to anyone with access to the file. If you want to use the default login credentials then you don’t need to mention anything in the code. You can comment the line of code.
$User =
'abcd'
$Pass = ConvertTo-SecureString
''
abcd@
#2016
' -AsPlainText -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Pass
Import Server and Drive details
01.
#Import the file to get the drives status and other usage details
02.
03.
#The Import-Csv cmdlet provides a way for you to read in data from a comma-separated values file (CSV)
04.
05.
Import-Csv $InputServer|%{
06.
$cserver = $_.Server
07.
$cdrivelt = $_.Drive
08.
$clowth = $_.LowTh
09.
$cwarnth = $_.WarnTh
10.
$ccritth = $_.CritTh
11.
$cemail = $_.Email
12.
$clowpri = $_.LowPri
13.
$cwarnpri = $_.WarnPri
14.
$ccritpri = $_.CritPri
15.
$cescinst = $_.EscInst
16.
If (!(Test-Connection $_.Server -count
1
-quiet)) {
17.
#Write the message to the log file
18.
Write-Log -
level
ERROR -Message
"$($_.Server) is not reachable"
-Logfile $Logfile
19.
}
20.
else
21.
{
22.
#Write the Progress to log file
23.
Write-Log -Message
"$($_.Server) is reachable and starting the process "
-Logfile $Logfile
24.
25.
$diskinfo= Get-WmiObject -Class Win
32
_LogicalDisk -ComputerName $cserver -Filter
"DeviceID='$cdrivelt'"
26.
ForEach ($disk in $diskinfo)
27.
{
28.
#Calculate the % free. This parameter will be compared with various thresholds to derive the status of the drive
29.
If ($diskinfo.Size -gt
0
) {$percentFree = [Math]::round((($diskinfo.freespace/$diskinfo.size) *
100
))}
30.
Else {$percentFree =
0
}
31.
#Determine if disk needs to be flagged for warning or critical alert
32.
If ($diskinfo.Size -gt
0
) {$percentFree = [Math]::round((($diskinfo.freespace/$diskinfo.size) *
100
))}
33.
Else {$percentFree =
0
}
34.
If ($percentFree -le $ccritth) {
35.
36.
$status =
"Critical"
37.
$priority = $ccritpri
38.
$body = @"
39.
Notification that a disk drive is reporting an alert for
low
disk space!
40.
$cserver $cdrivelt has $percentFree % free space. Please assign an $priority priority ticket to the $cescinst team.
41.
-This is an automated email being generated by the script DiskMonCheck.ps
1
, as a scheduled task on HQMONP
09
.
42.
"@
43.
Send-MailMessage -to $cemail -from
"HQMONP09@appvion.com"
-Subject
"Disk Alert - $cserver $cdrivelt out of disk space!"
-body $body -smtpserver $SMTPServer
44.
Write-Log -Message
"$($_.Server) Critical alert logged for the drive $cdrivelt "
-Logfile $Logfile
45.
46.
}
Output
This section describes various options available in the script to validate the disk space data
Log filename
This below code defines the output log file location, and directory to save the output. The $date variable hold the date formatting part. It’s then appended to the $logfilename to generate a more meaningful filename. For example, DiskSpaceLog_2016-10-10
$date=Get-Date -
format
"yyyy-MM-d"
#Prepare log file and output CSV file
$LogFileName=
"DiskSpaceLog_$($date)"
Email
$body = @"
Notification that a disk drive is reporting an alert for
low
disk space!
$cserver $cdrivelt has $percentFree % free space. Please assign an $priority priority ticket to the $cescinst team.
-This is an automated email being generated by the script DiskMonCheck.ps
1
, as a scheduled task on HQMONP
09
.
"@
Send-MailMessage -to $cemail -from
"HQMONP09@appvion.com"
-Subject
"Disk Alert - $cserver $cdrivelt out of disk space!"
-body $body -smtpserver $SMTPServer
Console
$mydisk +=New-Object PSObject -Property @{
Server=$_.Server
DeviceID= $disk.DeviceID
VolumeName= $disk.VolumeName
Size= [math]::Round(($disk.Size /
1
GB),
2
)
Usedspace= [math]::Round((($disk.Size - $disk.FreeSpace)/
1
GB),
2
)
Percentage= (
"{0:P}"
-f ($disk.FreeSpace / $disk.Size))
status=$status
}
}
}
}
$mydisk |Select-Object @{Name=
"Server"
;Expression={$_.Server}},@{Name=
"DeviceID"
;Expression={$_.DeviceID}},
@{Name=
"VolumeName"
;Expression={$_.VolumeName}},
@{Name=
"Size"
;Expression={$_.Size}},
@{Name=
"Used Space"
;Expression={$_.Usedspace}},
@{Name=
"% Free"
;Expression={$_.Percentage}},
@{Name=
"Status"
;Expression={$_.status}}|Format-Table -AutoSize
Code
<#
.Synopsis
The objective of the script is to make use of .csv files as sources for various parts of the script.
.Description
Function to log manipulate the date based on the input file and display it to console. Log entries in the log file are time stamped. By
default
the message are logged under INFO category. It can be changed to other category such as
"WARN"
and
"Error"
using -
level
parameter
.Parameter InoutFile
Path to the file where the input details are saved.
Example: c:\InputServer.csv
.Parameter SMTPServer
The SMTP server name to send email to respective intendencies
Example: ancd.gmail.com
.Example
Write-Log -Message
"$($_.Server) is reachable and starting the process "
-Logfile $Logfile
.Example
Write-Log -Message
"$($_.Server) Critical alert logged for the drive $cdrivelt "
-Logfile $Logfile
.Link
https://powershellsql.wordpress.com/
.Notes
The CSV file is going to hold
all
the metadata for each drive that you intend to monitor and send out notification
#>
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact=
'Low'
)]
Param(
[Parameter(Mandatory=$true,
Position=
0
)]
[String]$InputServer,
[Parameter(Mandatory=$true,
Position=
1
)]
[String]$DirectorytoSave,
[Parameter(Mandatory=$true,
Position=
2
)]
[String]$SMTPServer
)
# formatting the date
$date=Get-Date -
format
"yyyy-MM-d"
#Prepare log file and output CSV file
$LogFileName=
"DiskSpaceLog_$($date)"
# before we do anything else, are we likely to be able to save the file?
# if the directory doesn't exist, then create it
if (!(Test-Path -path
"$DirectoryToSaveTo"
)) #create it if not existing
{
New-Item
"$DirectoryToSaveTo"
-type directory | out-null
}
#log File creation
$logfile =
"$DirectoryToSave$LogFileName.log"
if (!(Test-Path -path
"$logfile"
)) #create it if not existing
{
New-Item -ItemType file $logfile -Force
}
# Prepare headers for the log file for each execution of script
Add-Content $logfile
"#################################################################"
Add-Content $logfile
"Disk Space Details"
Add-Content $logfile
"Generated $(get-date)"
Add-Content $logfile
"Generated from $(gc env:computername)"
Add-Content $logfile
"#################################################################"
Function Write-Log {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False)]
[ValidateSet(
"INFO"
,
"WARN"
,
"ERROR"
)]
[String]
$Level =
"INFO"
,
[Parameter(Mandatory=$True)]
[string]
$Message,
[Parameter(Mandatory=$False)]
[string]
$logfile
)
$Stamp = (Get-Date).toString(
"yyyy/MM/dd HH:mm:ss"
)
$Line =
"$Stamp $Level $Message"
If($logfile) {
Add-Content $logfile -Value $Line
}
Else {
Write-Output $Line
}
}
#Creating PowerShell custom objects
$Mydisk=@()
#Import the file to get the drives status and other usage details
#The Import-Csv cmdlet provides a way for you to read in data from a comma-separated values file (CSV)
Import-Csv $InputServer|%{
$cserver = $_.Server
$cdrivelt = $_.Drive
$clowth = $_.LowTh
$cwarnth = $_.WarnTh
$ccritth = $_.CritTh
$cemail = $_.Email
$clowpri = $_.LowPri
$cwarnpri = $_.WarnPri
$ccritpri = $_.CritPri
$cescinst = $_.EscInst
If (!(Test-Connection $_.Server -count
1
-quiet)) {
#Write the message to the log file
Write-Log -
level
ERROR -Message
"$($_.Server) is not reachable"
-Logfile $Logfile
}
else
{
#Write the Progress to log file
Write-Log -Message
"$($_.Server) is reachable and starting the process "
-Logfile $Logfile
$diskinfo= Get-WmiObject -Class Win
32
_LogicalDisk -ComputerName $cserver -Filter
"DeviceID='$cdrivelt'"
ForEach ($disk in $diskinfo)
{
#Calculate the % free. This parameter will be compared with various thresholds to derive the status of the drive
If ($diskinfo.Size -gt
0
) {$percentFree = [Math]::round((($diskinfo.freespace/$diskinfo.size) *
100
))}
Else {$percentFree =
0
}
#Determine if disk needs to be flagged for warning or critical alert
If ($diskinfo.Size -gt
0
) {$percentFree = [Math]::round((($diskinfo.freespace/$diskinfo.size) *
100
))}
Else {$percentFree =
0
}
If ($percentFree -le $ccritth) {
$status =
"Critical"
$priority = $ccritpri
$body = @"
Notification that a disk drive is reporting an alert for
low
disk space!
$cserver $cdrivelt has $percentFree % free space. Please assign an $priority priority ticket to the $cescinst team.
-This is an automated email being generated by the script DiskMonCheck.ps
1
, as a scheduled task on HQMONP
09
.
"@
Send-MailMessage -to $cemail -from
"HQMONP09@appvion.com"
-Subject
"Disk Alert - $cserver $cdrivelt out of disk space!"
-body $body -smtpserver $SMTPServer
Write-Log -Message
"$($_.Server) Critical alert logged for the drive $cdrivelt "
-Logfile $Logfile
}
ElseIf ($percentFree -gt $ccritth -AND $percentFree -le $cwarnth) {
$status =
"Warning"
$priority = $cwarnpri
$body = @"
Notification that a disk drive is reporting an alert for
low
disk space!
$cserver $cdrivelt has $percentFree % free space. Please assign a $priority priority ticket to the $cescinst team.
-This is an automated email being generated by the script DiskMonCheck.ps
1
, as a scheduled task on HQMONP
09
.
"@
Send-MailMessage -to $cemail -from
"HQMONP09@appvion.com"
-Subject
"Disk Alert - $cserver $cdrivelt disk space warning!"
-body $body -smtpserver $SMTPServer
Write-Log -Message
"$($_.Server) Warning alert logged for the drive $cdrivelt "
-Logfile $Logfile
}
ElseIf ($percentFree -ge $cwarnth -AND $percentFree -lt $clowth) { $status =
"Low"
$priority = $clowpri
$body = @"
Notification that a disk drive is reporting an alert for
low
disk space!
$cserver $cdrivelt has $percentFree % free space. Please assign a $priority priority ticket to the $cescinst team.
-This is an automated email being generated by the script DiskMonCheck.ps
1
, as a scheduled task on HQMONP
09
.
"@
Send-MailMessage -to $cemail -from
"HQMONP09@appvion.com"
-Subject
"Disk Alert - $cserver $cdrivelt disk space warning!"
-body $body -smtpserver $SMTPServer
Write-Log -Message
"$($_.Server) low alert logged for the drive $cdrivelt "
-Logfile $Logfile
}
Else { $status =
"Good"
}
$mydisk +=New-Object PSObject -Property @{
Server=$_.Server
DeviceID= $disk.DeviceID
VolumeName= $disk.VolumeName
Size= [math]::Round(($disk.Size /
1
GB),
2
)
Usedspace= [math]::Round((($disk.Size - $disk.FreeSpace)/
1
GB),
2
)
Percentage= (
"{0:P}"
-f ($disk.FreeSpace / $disk.Size))
status=$status
}
}
}
}
$mydisk |Select-Object @{Name=
"Server"
;Expression={$_.Server}},@{Name=
"DeviceID"
;Expression={$_.DeviceID}},
@{Name=
"VolumeName"
;Expression={$_.VolumeName}},
@{Name=
"Size"
;Expression={$_.Size}},
@{Name=
"Used Space"
;Expression={$_.Usedspace}},
@{Name=
"% Free"
;Expression={$_.Percentage}},
@{Name=
"Status"
;Expression={$_.status}}|Format-Table -AutoSize
Output
Compare Mail Inbox view with PoSH output
Log file details are shown below
Running DiskSpace.ps1 file with parameters
Conclusion
As usual, any feedback is welcome, and I hope that this article was helpful to you!
References
Technet
See Also
Share this:
Like this:
About Prashanth Jayaram
DB Technologist, Author, Blogger, Service Delivery Manager at CTS, Automation Expert, Technet WIKI Ninja, MVB and Powershell Geek My Profile: https://social.technet.microsoft.com/profile/prashanth jayaram/ http://www.sqlshack.com/author/prashanth/ http://codingsight.com/author/prashanthjayaram/ https://www.red-gate.com/simple-talk/author/prashanthjayaram/ http://www.sqlservercentral.com/blogs/powersql-by-prashanth-jayaram/ Connect Me: Twitter @prashantjayaram GMAIL powershellsql@gmail.com The articles are published in: http://www.ssas-info.com/analysis-services-articles/ http://db-pub.com/ http://www.sswug.org/sswugresearch/community/