Database information and drive space in one function

Good day all,
I'm trying to come up with a function that I can run across all mailbox servers in my environment; gathering information such as drives presented to it, drive capacity, drive free space, database size, mbx count, avg mbx size, database whitespace, etc..
I start running into errors when I wanted to add the drive report to this. Can anyone take a look and see where im faulting? When I run this I get  "you cannot call a method on a null-valued expression.'
Thank you for your help.
function DatabaseStatistics{
$ExchangeServers = get-exchangeserver
$Drivespace = Get-wmiobject win32_logicaldisk -computername $ExchangeServers
foreach($Drive in $drivespace) {
$DrFree = $drivespace.deviceid.freespace
$DrSize = $drivespace.deviceid.volumename.size
$Databases = Get-MailboxDatabase * -Status
foreach($Database in $Databases) {
$DBSize = $Database.DatabaseSize
$MBCount = @(Get-MailboxStatistics -Database $Database.Name).Count
$MBAvg = Get-MailboxStatistics -Database $Database.Name |
%{$_.TotalItemSize.value.ToMb()} |
Measure-Object -Average
New-Object PSObject -Property @{
Server = $Database.Server.Name
DatabaseName = $Database.Name
LastFullBackup = $Database.LastFullBackup
MailboxCount = $MBCount
"DatabaseSize (GB)" = $DBSize.ToGB()
"AverageMailboxSize (MB)" = $MBAvg.Average
"WhiteSpace (MB)" = $Database.AvailableNewMailboxSpace.ToMb()
"Drive and Capacity" = $drsize.toGB()
"Drive Freespace" = $drfree.toGB()

Here is how you should approach this.  It is more efficient and will produce less errors.  I didn't test it I just wanted to point you in a better direction. 
Don't try to convert numbers until you have collected all of the data.  The formatter pass always comes at the end.
The WMI needs to be looked at.  I didn't look up how to get eth drive letter.  It needs to be extracted from the database file path.
function DatabaseStatistics{
$servers=get-exchangeserver
foreach($server in $servers){
$p=@{
Server=$server.Name
DatabaseName=$null
LastFullBackup=$null
MailboxCount=$null
DatabaseSize=$null
AverageMailboxSize=$null
WhiteSpace=$null
DriveSize=$null
DriveFreespace=$null
$databases=Get-MailboxDatabase -Server $server
foreach($database in $databases){
$p.DatabaseSize=$database.DataBaseSize
$p.DatabaseName=$database.Name
$values=Get-MailboxStatistics -Database *|%{$_.ToTalItemSize.Value}|Measure-Object -Average
$p.MailBoxCOunt=$values.Count
$p.AverageMailboxSize=$values.Average
$p.LastFullBackup=$database.LastFullBackup
$p.WhiteSpace=$database.AvailableNewMailboxSpace
$edbpath=$database.edbFilePath.PathName
$d=([io.fileinfo]$edbpath).Directory.Root.Name.Replace('\','') #'
$drv=Get-WmiObject Win32_LogicalDisk -Filter "Name='$d'" -Computer $server
$p.DriveSize=$drv.Size
$p.DriveFreeSpace=$drv.Freespace
New-Object PSObject -Property $p
DatabaseStatistics
¯\_(ツ)_/¯

Similar Messages

  • How to add drive space from one drive to another drive in Solaris 10

    This is something I have never done in Solaris. I have a mounted drive (UFS) with a dir being used for a samba share. The dir is near full. I have another drive right beside it that is empty.
    1. How can I add the drive space from the empty drive to the dir or drive that is nearly full? I have to access all files on both drives from the samba share.
    2. Can I do this without loosing files?
    3. Can I do this without messing up the samba share?
    4. Can this be done on the fly without re-boot?
    Thanks in advance.

    I would start by getting acquainted with ZFS.
    Make sure you have a recent Solaris 10 version with a stable zfs impl. like u4 and later.
    Make sure you have installed reasonably recent Solaris 10 recommended patches - they make a big difference to ZFS.
    Simple solution :
    * put your new drive in a zpool
    # zpool create smbpool <new_drive_device, fx. c0t1d0>
    * make a zfs
    # zfs create smbpool/smbfs
    * stop your samba server
    # svcadm stop smb ?
    * copy your files to your zfs fssmb_ufs=old samba fs
    # cp -rp <old_samba_fs> /pools/smbpool/smbfs
    * un-mount and say goodbye to your old samba fs - /wave
    # umount <old_samba_fs>
    * expand your zpool with the old samba server fs partition
    # zpool add smbpool <device name for old samba slice, fx. c0t0d0s6>
    * move your zfs fs to be mounted on the same mount points as the old samba server fs
    # zfs set mountpoint=<old_samba_mountpoint> smbpool/smbfs
    * restart your samba server
    # svcadm start smb ?
    It requires downtime for the samba server to copy the files, which could be cut shorter by using rsync, rsyncing while samba server online, stop samba server, rsync again for the changes while the first rsync ran.

  • How to delete bank information and add a new one

    as an ios  develper i need to edit banking and tax. it doesnt give edit option , only the view option and i need to delete the bank information and add new one .

    If you can't change the required information in the Member Center, contact [email protected] see if they can help, etc.

  • Database, iAS and iDS installed in one box

    I would like to install 9.2.0.1 Database, 9.0.4.1 iAS and 9.0.4.1 iDS all in one box, Does any body have ever had this experience before? please share your experience with me, or at least could advice me where I can find the resource or article. Thank's and best regards.

    Database Installation

  • Final Cut Studio2 and drive space

    1. Does anyone know how much space takes up the FCP Studio 2 with the content?
    I have about 50GB left.
    2. Can I install the Application on the main drive and Content on the external?
    Thanks,

    #1 From Apple's FCP site:
    Available Disk Space
    • 4GB of disk space required to install all applications
    • Additional 62GB required to install all optional templates, content, and tutorials (may be installed on separate disks):
    - 9GB for DVD Studio Pro content
    - 8GB for Motion templates and tutorial media
    - 24GB for Soundtrack Pro audio content
    - 12GB for LiveFonts and LiveType animated elements and templates
    - 2GB for Apple Pro Training Final Cut Studio Tutorials media
    #2 Yes, you will have the option to install "extras" on another volume .... just as it was with FCS 1. Read the included "Installing Your Software" booklet for details.
    -DH

  • How I can move my GB songs to a CD so I can free up hard drive space?

    Whenever I attempt to move a GB song onto a CD (to free up hard drive space) and delete the song from the GB folder, I'm not able to open up the song. Any advice?
    iBook G4   Mac OS X (10.4.4)  

    Thank you for your advice.
    Ultimately you are correct about the CD-R not being reusable once the file is burned.
    Presently I've alleviated that by not burning the CD-R. However, the downside is that I will not be able to remove the CD-R from the drive until I either burn the songs to the CD-R, or move the songs back onto the hard drive.
    Perhaps a CD-RW may allow one to move files back and forth in the same manner that floppy disks do (though a GarageBand file obviously would be much too large to store on a floppy). This may be a temporary "poor person's" solution to free up hard drive space until one can afford a zip drive or a larger Mac.
    Thank you again for your tip.
    Cheers,
    John
    iBook G4   Mac OS X (10.4.4)  

  • Read parked and posting document from one FM

    Hi all,
    IS theere any FM avaliable to read parked and posting document from one function module.
    Please let me know if anything is there.
    Thanks

    Hi T,
    have u searched in SE37 with words park?,i'm sure we have few FMs which will do the same.
    regards
    Prabhu

  • What is Database Commit and Database Rollback.

    What is Database Commit and Database Rollback.

    Hi Sir ,
    Please have a look below .Hope it is suitable and simpler solution for your question.
    Please do reward if useful.
    Thankx.
    In database level this will be used..
    Commit is nothing but SAVE the current record..
    If u rol back before commit means whatever u proceeded for the SAVING will be roll back and the data will not be stored..
    This will be used,When some times u r filling a register form..after filling 20 fields,In the 21st field u will not to registrer means it will be rollbacked using the Rollbeck command.
    In detail--->
    ROLLBACK->
    In a ROLLBACK, all the changes made by a transaction or a subtransaction on the database instance are reversed.
    · Changes closed with a COMMIT can no longer be reversed with a ROLLBACK.
    · As a result of a ROLLBACK, a new transaction is implicitly opened.
    In normal database operation, the database system performs the required ROLLBACK actions independently. However, ROLLBACK can also be explicitly requested using appropriate SQL statements.
    In a restart, the system checks which transactions were canceled or closed with a ROLLBACK. The actions are these transactions are undone.
    COMMIT->
    In a COMMIT, all the changes made by a transaction or a subtransaction on the database instance are recorded.
    · Changes closed with a COMMIT can no longer be reversed with a ROLLBACK.
    · As a result of a COMMIT, a new transaction is implicitly opened.
    In normal database operation, the database system performs the required COMMIT actions independently. However, COMMIT can also be explicitly requested using appropriate SQL statements.
    In a restart, the system checks which transactions were closed with a COMMIT. These actions are redone. Transactions not yet closed with a COMMIT are undone.
    From the point of view of database programming, a database LUW is an inseparable sequence of database operations that ends with a database commit. The database LUW is either fully executed by the database system or not at all. Once a database LUW has been successfully executed, the database will be in a consistent state. If an error occurs within a database LUW, all of the database changes since the beginning of the database LUW are reversed. This leaves the database in the state it was in before the transaction started.
    the statements
    COMMIT WORK.
    and
    ROLLBACK WORK.
    for confirming or undoing database updates. COMMIT WORK always concludes a database LUW and starts a new one. ROLLBACK WORK always undoes all changes back to the start of the database LUW.

  • Please for referral information, how can I get more disk space, or actually information and guidelines that can have enough free disk space. How, I have to delete documents or downloading to another drive.

    Please for referral information, how can I get more disk space, or actually information and guidelines that can have enough free disk space. How, I have to delete documents or downloading to another drive. (The problem is that Safari could not download the file "iTunesSetup.exe" because there is not enough free disk space.Try deleting documents or downloading to another drive) ... Perhaps this is the main problem why can not open iTunes and inscription is: the folder "iTunes" can not be found or created, and is required. The default location for this folder is inside the "Music" folder. - And after options ok, appears option: Choose iTunes Library with inscription iTunes needs a library to continue. You may choose an existing iTunes library or create a new one - but still following options Choose Library and the following options can not open iTunes ... Please for instructions on how to eliminate the problem or eror ...
    Mac is running OS X v10.6.8, Safari should be 5.1.10. Or  Mac OS X  /  Version  10.6.8  /  Build 10K549 / Serial Number W8****ATM  /  Processor 2.4 GHz Intel Core 2 Duo  /  Memory 4 GB 1067 MHz DDR3 or More Info:
    Hardware Overview:
      Model Name: MacBook Pro
      Model Identifier: MacBookPro7,1
      Processor Name: Intel Core 2 Duo
      Processor Speed: 2,4 GHz
      Number Of Processors: 1
      Total Number Of Cores: 2
      L2 Cache: 3 MB
      Memory: 4 GB
      Bus Speed: 1,07 GHz
      Boot ROM Version: MBP71.0039.B0B
      SMC Version (system): 1.62f7
      Serial Number (system): W80394HFATM
      Hardware UUID: 94647506-C5D0-5D73-BC7F-FC680D238F43
      Sudden Motion Sensor:
      State: Enabled
    <Personsl Information Edited by Host>

    buy an external HD   1TB for $60
    NO notebook is a mass storage device, so dont try to turn it into one, it doesnt work that way.
    Unless youre using it every couple weeks, its static data and should be on an external HD
    In the case of a Macbook Air or Macbook Pro Retina with ‘limited’ storage on the SSD, this distinction becomes more important in that in an ever rapidly increasing file-size world, you keep vital large media files, pics, video, PDF collections, music off your SSD and archived on external storage, for sake of the necessary room for your system to have free space to operate, store future applications and general workspace.  You should never be put in the position of considering “deleting things” on your macbook SSD in order to ‘make space’.
    Professionals who create and import very large amounts of data have almost no change in the available space on their computers internal HD because they are constantly archiving data to arrays of external or networked HD.
    Or in the case of the consumer this means you keep folders for large imported or created data and you ritually offload and archive this data for safekeeping, not only to safeguard the data in case your macbook has a HD crash, or gets stolen, but importantly in keeping the ‘breathing room’ open for your computer to operate, expand, create files, add applications, for your APPS to create temp files, and for general operation.

  • How can one find out how much hard drive space the apps and media are using?

    how can one find out how much hard drive space the apps and media are using?

    See Here  >  Where did my Disk Space go?
    And Here  >  The Storage Display

  • I have a power mac and the hard drive is about to die, i have a new hard drive to install, i know how to remove and put the old in the second space and load the new one, then what...when do reinstall the OS and transfer data from old drive

    I have a power mac, the hard drive is struggling, I have a new hard drive ready to install, after I pull the old one and put the new one it's place and place the old one in the next slot ready to transfer data....how do I start this next step.  Do I down load OS, and go to utililities...please just a step by step after hard drives in position.

    Hi Susan, you must have a Mac Pro, Powermacs cannot run 10.6.x
    Anyway, once you Install the new drive, you likely must Format it...
    How to format your disks...
    http://www.kenstone.net/fcp_homepage/partitioning_tiger.html
    (To Install OSX on an IntelMac the Drive it needs the GUID Partitioning scheme mentioned at the bottom.)
    Thanks to Pondini, Formatting,  Partitioning, Verifying,  and  Repairing  Disks...
    http://web.me.com/pondini/AppleTips/DU.html
    Then Install the OS & on first boot of the new install, after a step or two, avail yourself of Migration Assistant & Migrate everything.

  • Can you merge two user accounts on macbook? my wife has created a user on her new macbook , then inadvertently created a second one when using the migration tool. 1st ac has her office 365 install, yet 2nd has her itunes database, docs and contacts.

    Can you merge two user accounts on a macbook? my wife has created a new user on her new macbook air then, inadvertently, created a second one when using the migration tool. 1st a/c has her office 365 install, while 2nd has her itunes database, docs and contacts. What is the best way forward to get everything into the one account? Not sure if the office 365 will allow another installation into the second account, otherwise would just do that and delete the first, if that is possible?

    There is no merge but you can move data from one account to another via the Shared folder. Data is copied from Shared. Watch your free space when copying. These are large files.  Do one at a time if you are on a small drive. After making copy, delete from other users before you start next copy.
    Office365 installs in the main Applications folder and is available for all users on the computer. Activation is tied to the drive not the User.

  • We have created two partitions in removable drive(USB). One of the partition is active and the other is hidden. We are trying to acess the hidden partition in Win PE 3.0 environment using WMI

    We have created two partitions in removable drive(USB). One of the partition is active and the other is hidden. We are trying to access the hidden partition in Win PE 3.0 environment using WMI. VBScript code snippet used to detect the partitions is given
    below:- 
    SetobjWMIService = GetObject("winmgmts:"_&
    "{impersonationLevel=impersonate}!\\"&
    strComputer & "\root\cimv2")
    SetcolDisks = objWMIService.ExecQuery
    Select * from Win32_LogicalDisk")
    It will return the partition which is active but fails to list the partition which is hidden. The same piece of code was supported on WinPE 2.0

    I am giving the complete code, may be you are able to understand better. We are using Win32_LogicalDisk to retrieves the complete information of all the drives (like C:, D:) including removable drives. 
    Function
    LocalDriveFound()
        strComputer =
    SetobjWMIService = GetObject("winmgmts:"_
    "{impersonationLevel=impersonate}!\\"&
    strComputer & "\root\cimv2")
    SetcolDisks = objWMIService.ExecQuery
    "Select * from Win32_LogicalDisk")
    ForEachDiskDrive
    IncolDisks
            DriveLetter = Left(DiskDrive.Name,1)
            DriveType = DiskDrive.DriveType
            VolumeName = DiskDrive.VolumeName
            WScript.echo Driveletter &
    "|"& Drivetype &
    "|"&VolumeName
    SelectCaseDriveType
    Case2 ,3  
    'Fixed or removable
    If(VolumeName=USBVolumeName)
    Then
    If(DriveLetter<>
    "Z")
    Then
                        ChangeDriveLetterWithMountvol DriveLetter,
    "Z"
    EndIf
                    bIsLocal=
    True
    EndIf 
    If(VolumeName=USBRootName)
    Then
    If(DriveLetter<>
    "Y")
    Then
                        ChangeDriveLetterWithMountvol DriveLetter,
    "Y"
    EndIf
                    bIsLocal=
    True
    EndIf 
    CaseElse
    EndSelect
    Next
    SetDrives =
    Nothing
    SetFileSystemObject =
    Nothing
    End
    Function

  • We have a very big issue here, Patch Tuesday didn't work correctly yesterday, and the patches took all the free drive space away.

    Hello
    We have a very big issue here, Patch Tuesday didn't work correctly yesterday, and the patches took all the free drive space away.
    Before we started with the Patches, we had one Gig of free space on our hard drive, now we are down to less than 10 Megs!!!
    What happened is that the patches didn't work, we had to try them 7 times, and every time they created a 'temporary restore point' which we don't know where that point is.
    The server has crashed twice since, we were able to place it back online but we're afraid it will crash again.
    We have several customers on that server, we are very worried,
    Can you please help us?
    Thank you

    Hi,
    Hope the below article be helpful:
    Clear space on your hard drive by deleting old Windows uninstall folders
    http://news.cnet.com/8301-13880_3-9862223-68.html
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    And as far as I know, we could not use diskpart to extend C drive, 3rd party utilities may work, please go through the below thread:
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/03068ecb-7edd-43d8-bc68-12bc466c583f/how-to-extend-the-windows-2003-c-drive?forum=winservergen
    Regards,
    Yan Li
    Regards, Yan Li

  • I have a new Windows tablet computer with limited hard drive space, and cannot transfer my itunes library to the hard drive. Can I run t media from an external hard drive? If so, how do I transfer my files?

    I have a new Windows tablet computer with limited hard drive space (32 GB), and cannot transfer my itunes library to the hard drive. Can I run itunes from an external hard drive? I have tried to follow some of the directions on this site, but am having no success. Thanks.

    iTunes will run fine with the media on an external drive.
    However, I suggest that a tablet computer with a tiny hard drive is not ideal as the primary computer for managing an iTunes library, even a small one. If you have another machine, perhaps a big, boxy, inexpensive old desktop with a decent amount of storage, that might be a better choice.
    http://support.apple.com/kb/HT1364

Maybe you are looking for

  • Security Optimization Self-Service. Checking profiles

    Dear All, I am using Security Optimization Self-Service and would like to know if there is a way to implement a "customer specific authorization check" to evaluated if somebody is granted with profiles SAP_NEW or SAP_ALL_DISPLAY. I will appreciate id

  • ISE and RSA token groups

    We have wireless  network using ISE and RSA to do the authenticaiton. There are two groups of RSA token users, one is with username Axxxx, the other Bxxxx. Now we try to differ the authentications for the two group. One permit, the other deny. I am w

  • OSB Xquery mapping from multiple to single by separating its value(s).

    Hi, I have one requirement in OSB, can some one explain the implementation for this: I have one element which is of type unbound. I need to map this element to a single element and to append all the element values by separating each element value wit

  • Without api

    hello guys, i am working in java, as u all know java uses standard api for everything i want some piece of code for say anything like opening a text file and reading its contents without using api means the coder will code from beginning... thanks.

  • My Season pass to the Walking Dead Season 2 will not download or show Episode 3 is available

    Episode 3 is not showing up when i check available downloads and thus i cannot download it. Episode 3 of season 2 is already available for purchase on the Walking dead page but for some reason it is not working, please help, i know others are experie