Windows Vista Forums

How can I know if a drive/directory is NTFS or FAT
  1. #1


    DavieH Guest

    How can I know if a drive/directory is NTFS or FAT

    The Command method is to use CACLS <drive/dir> which returns 1 if the
    filesystem is *not* NTFS. CACLS is deprecated but ICACLS only returns a
    text messsage. The nearest I get in PS is (get-item -path <drive>).attributes
    e.g. hidden, system, directory. Is there a way comparable to CACLS?



    thanks,
    DavieH
    ===

      My System SpecsSystem Spec

  2. #2


    Charlie Russel - MVP Guest

    Re: How can I know if a drive/directory is NTFS or FAT

    Get-WMIObject win32_logicaldisk -filter drivetype=3 | select
    deviceID,Filesystem

    would give you the drive letter and filesystem for all of your fixed disks.

    --
    Charlie.
    http://msmvps.com/blogs/xperts64
    http://mvp.support.microsoft.com/profile/charlie.russel

    "DavieH" <DavieH@xxxxxx> wrote in message
    news:BAC6E166-E16E-444B-A9C4-13063BA2A16A@xxxxxx

    > The Command method is to use CACLS <drive/dir> which returns 1 if the
    > filesystem is *not* NTFS. CACLS is deprecated but ICACLS only returns a
    > text messsage. The nearest I get in PS is (get-item -path
    > <drive>).attributes
    > e.g. hidden, system, directory. Is there a way comparable to CACLS?
    >
    > thanks,
    > DavieH
    > ===

      My System SpecsSystem Spec

  3. #3


    Charlie Russel - MVP Guest

    Re: How can I know if a drive/directory is NTFS or FAT

    Or, if you know the drive letter and want the filesystem, you could do
    something like:

    PSH> $Filesystem=$(Get-WMIObject win32_logicaldisk -filter "DeviceID = 'D:'
    ").filesystem

    PSH> $Filesystem
    NTFS

    --
    Charlie.
    http://msmvps.com/blogs/xperts64
    http://mvp.support.microsoft.com/profile/charlie.russel

    "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
    news:OGsX5nchJHA.996@xxxxxx

    > Get-WMIObject win32_logicaldisk -filter drivetype=3 | select
    > deviceID,Filesystem
    >
    > would give you the drive letter and filesystem for all of your fixed
    > disks.
    >
    > --
    > Charlie.
    > http://msmvps.com/blogs/xperts64
    > http://mvp.support.microsoft.com/profile/charlie.russel
    >
    > "DavieH" <DavieH@xxxxxx> wrote in message
    > news:BAC6E166-E16E-444B-A9C4-13063BA2A16A@xxxxxx

    >> The Command method is to use CACLS <drive/dir> which returns 1 if the
    >> filesystem is *not* NTFS. CACLS is deprecated but ICACLS only returns a
    >> text messsage. The nearest I get in PS is (get-item -path
    >> <drive>).attributes
    >> e.g. hidden, system, directory. Is there a way comparable to CACLS?
    >>
    >> thanks,
    >> DavieH
    >> ===
    >

      My System SpecsSystem Spec

  4. #4


    DavieH Guest

    Re: How can I know if a drive/directory is NTFS or FAT

    Perfect - thank you.
    I wouldn't have gone near WMI by myself!

    DavieH
    ===

    "Charlie Russel - MVP" wrote:

    > Or, if you know the drive letter and want the filesystem, you could do
    > something like:
    >
    > PSH> $Filesystem=$(Get-WMIObject win32_logicaldisk -filter "DeviceID = 'D:'
    > ").filesystem
    >
    > PSH> $Filesystem
    > NTFS
    >
    > --
    > Charlie.

      My System SpecsSystem Spec

  5. #5


    Charlie Russel - MVP Guest

    Re: How can I know if a drive/directory is NTFS or FAT

    The thing is, WMI is almost easy in PowerShell. Seriously, I NEVER used it
    in VB - it was just too hard. But Get-WMIObject is definitely a lot easier
    to get your head around.

    --
    Charlie.
    http://msmvps.com/blogs/xperts64
    http://mvp.support.microsoft.com/profile/charlie.russel

    "DavieH" <DavieH@xxxxxx> wrote in message
    news:7F975802-1CA2-44D9-8AF2-E36FA737AE06@xxxxxx

    > Perfect - thank you.
    > I wouldn't have gone near WMI by myself!
    >
    > DavieH
    > ===
    >
    > "Charlie Russel - MVP" wrote:
    >

    >> Or, if you know the drive letter and want the filesystem, you could do
    >> something like:
    >>
    >> PSH> $Filesystem=$(Get-WMIObject win32_logicaldisk -filter "DeviceID =
    >> 'D:'
    >> ").filesystem
    >>
    >> PSH> $Filesystem
    >> NTFS
    >>
    >> --
    >> Charlie.
    >

      My System SpecsSystem Spec

  6. #6


    DavieH Guest

    Re: How can I know if a drive/directory is NTFS or FAT

    I've been working on it and can figure the win32_logicaldisk class well
    enough to see where the available properties (filesystem and DeviceId) come
    from, and write an elaborate function to get the filesystem from a folder
    name!
    The simple way is to adapt the query you provided:-

    (Get-WMIObject win32_logicaldisk -filter "DeviceID = '$drive'").filesystem

    Why does it work without the $? What does the $ effectively do (or not do!)?


    Thanks,
    DavieH
    ===


    "Charlie Russel - MVP" wrote:

    > The thing is, WMI is almost easy in PowerShell. Seriously, I NEVER used it
    > in VB - it was just too hard. But Get-WMIObject is definitely a lot easier
    > to get your head around.
    >
    > --
    > Charlie.
    ....

    > >> PSH> $Filesystem=$(Get-WMIObject win32_logicaldisk -filter "DeviceID =
    > >> 'D:'").filesystem

      My System SpecsSystem Spec

  7. #7


    Charlie Russel - MVP Guest

    Re: How can I know if a drive/directory is NTFS or FAT

    You're quite right, the $ was actually left over from something I was doing
    to check that answer before I posted it, and it's fine without.

    I'm quite pleased that you were able to take my fairly simplistic answer,
    and get to where you wanted to be. Isn't PowerShell fun? I make no pretense
    of being a PowerShell guru - there are lots of those posting here, and
    sometimes they simply amaze me. But I spent many, many years as a sysadmin
    on unix and windows systems before I turned to writing about OSs full time,
    and the part I really miss about being a full time admin is the scripting.
    So I muck around a bit, and try to add scripts to my chapters as
    appropriate, and I use PowerShell as my every day shell. And try to answer
    the occasional question when I get the chance since it always makes me
    stretch a bit.

    --
    Charlie.
    http://msmvps.com/blogs/xperts64
    http://mvp.support.microsoft.com/profile/charlie.russel

    "DavieH" <DavieH@xxxxxx> wrote in message
    news:E781D641-9F37-4975-B9C3-7C7D50085B89@xxxxxx

    > I've been working on it and can figure the win32_logicaldisk class well
    > enough to see where the available properties (filesystem and DeviceId)
    > come
    > from, and write an elaborate function to get the filesystem from a folder
    > name!
    > The simple way is to adapt the query you provided:-
    >
    > (Get-WMIObject win32_logicaldisk -filter "DeviceID = '$drive'").filesystem
    >
    > Why does it work without the $? What does the $ effectively do (or not
    > do!)?
    >
    >
    > Thanks,
    > DavieH
    > ===
    >
    >
    > "Charlie Russel - MVP" wrote:
    >

    >> The thing is, WMI is almost easy in PowerShell. Seriously, I NEVER used
    >> it
    >> in VB - it was just too hard. But Get-WMIObject is definitely a lot
    >> easier
    >> to get your head around.
    >>
    >> --
    >> Charlie.
    > ...

    >> >> PSH> $Filesystem=$(Get-WMIObject win32_logicaldisk -filter "DeviceID =
    >> >> 'D:'").filesystem
    >

      My System SpecsSystem Spec

How can I know if a drive/directory is NTFS or FAT problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
NTFS USB drive - can I reformat? Wolverine in Michigan Vista hardware & devices 2 12 Mar 2010
Cannot instal on NTFS drive Don Phillipson Virtual PC 2 09 Mar 2009
Re: Are the NTFS directory junctions mounted before Windows boot? Rick Rogers Vista General 0 01 Jan 2008
NTFS Drive to FAT32 CSM Vista General 12 05 Nov 2007
Cannot copy file from network share on NTFS drive to local NTFS drive MDaniel Vista General 5 18 Jan 2007