none
Ausgabe weiterverarbeiten RRS feed

  • Frage

  • Hallo liebe Community,

    ich bin leider noch blutiger PS Anfänger, möchte aber trotzdem gerne ein kleines Script erstellen. Und zwar möchte ich die DFS Pfade sichern und zwar alle (von allen Stämmen).

    Ich fange mit folgendem an:

    Get-DfsnRoot | select Path

    Dadurch kenne ich die Stämme und dann müsste ich ja weitermachen mit

    dfsutil root export \\domain.local\SHARE$  „D:\DFS\DFSBCK (get-date -format yyyy-MM-dd).xml“

    Ich scheitere daran die Ausgabe zu verwerten eben in genau diesen Export befehl. Mir ist wichtig, das automatisch alle Stämme erkannt werden und dann die DFS Pfade exportiert werden. Hat jemand eine Idee?

    Grüße

    Freitag, 21. August 2015 08:28

Antworten

  • Das sieht deutlich besser aus! Erst mal vielen Dank bis hierhin. Er gibt mir fünf Mal (fünf DFS Stämme) die Rückmeldung "Done processing this command." Jedoch befinden sich in der XML nur die Pfade von einem Stamm. Hast Du noch eine Idee?

    Ja das liegt daran, da du die Dateien immer überschreibst.

    So haben wir es dann für jeden Namespace separat:

    $DFSRoots = (Get-DFSNRoot).Path
    $Date = Get-Date -Format yyy-MM-dd
    ForEach ($Root in $DFSRoots)
        { 
           dfsutil root export $($Root) $("D:\DFSBCK-$Root-$Date.xml")
        }


    Greetings,

    David das Neves

    Technology Specialist - Consulting Services
    Computacenter AG & Co. oHG - München

    Blog    

    Caution: This post may contain errors.

    Freitag, 21. August 2015 13:59

Alle Antworten

  • Hi,

    Du solltest im eigentlichen Befehl nicht auch noch irgendwelche Powershell-CMDlets einbauen. Zieh Dir erst vorher alle Informationen, die Du für den Befehl brauchst, in entsprechende Variablen, z.B. so:

    $DFSRoots = (Get-DFSNRoot).Path
    $Date = Get-Date -Format yyyy-MM-dd

    Damit hast Du alle DFS-Stämme sowie das akt. Datum in einer Variable. Mit einer Schleife á la

    ForEach ($Root in $DFSRoots)
       {
       ...
       }

    kannst Du für jeden DFS-Stamm jeweils die gewünschten Aktionen durchführen. Deinen Befehl oben könntest Du dann wie folgt bauen (innerhalb der ForEach-Schleife):

    dfsutil root export $DFSRoot <Pfad>\DFSBCK-$Date.xml

    Gruß

    Ben

    MCSA Windows 8 (.1) MCSA Windows Server 2012 (R2)

    Wenn Dir meine Antwort hilft, markiere sie bitte entsprechend als Antwort! Danke! :-)

    Hinweis: Meine Posts werden "wie besehen" ohne jedwede Gewähr bereitgestellt, da menschliche, technische und andere Fehler nicht ausgeschlossen werden können.

    Freitag, 21. August 2015 09:11
  • Hi Ben,

    also so?

    $DFSRoots = (Get-DFSNRoot).Path
    $Date = Get-Date -Format yyy-MM-dd
    ForEach ($Root in $DFSRoots)
        { 
        dfsutil root export $DFSRoot D:\DFSBCK-$Date.xml
        }

    Wenn ich das so ausführe bekomme ich die Meldung:

    DESCRIPTION:
    Exports the namespace configuration information to a file.

    USAGE:
    dfsutil root export <\\server\share> <filename> [Verbose] [DownLevel]

    PARAMETERS:
    <\\server\share>  : UNC path to the namespace on the namespace server.
    <filename>        : Name of the file that will store the namespace
                        configuration in XML file format.
    Verbose           : Displays detailed status of the export process.
    Downlevel         : Saves the export file as a text file that is compatible
                        with the version of Dfsutil that is included with the
                        Windows Server 2003 Support Tools.
    Grüße

    Freitag, 21. August 2015 09:48
  • Hallo MeisteLampe

    versuch es mal so:

    $DFSRoots = (Get-DFSNRoot).Path
    $Date = Get-Date -Format yyy-MM-dd
    ForEach ($Root in $DFSRoots)
        { 
            Start-Process cmd.exe "/c dfsutil.exe root export `"$($DFSRoot)`" `"$(D:\DFSBCK-$Date.xml)`" "
        }


    Greetings,

    David das Neves

    Technology Specialist - Consulting Services
    Computacenter AG & Co. oHG - München

    Blog    

    Caution: This post may contain errors.

    Freitag, 21. August 2015 10:06
  • Hi David,

    funktioniert leider nicht:

    D:\DFSBCK-$Date.xml : The term 'D:\DFSBCK-$Date.xml' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
    of the name, or if a path was included, verify that the path is correct and try again.
    At C:\Users\user\Desktop\DFS.ps1:16 char:79
    +         Start-Process cmd.exe "/c dfsutil.exe root export `"$($DFSRoot)`" `"$(D: ...
    +                                                                               ~~
        + CategoryInfo          : ObjectNotFound: (D:\DFSBCK-$Date.xml:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
     

    Freitag, 21. August 2015 12:33
  • Sorry mein Fehler:

    $DFSRoots = (Get-DFSNRoot).Path
    $Date = Get-Date -Format yyy-MM-dd
    ForEach ($Root in $DFSRoots)
        { 
           dfsutil root export $($Root) $("D:\DFSBCK-$Date.xml")
        }
    

    Kann aktuell leider nicht testen. Probier das mal aus.


    Greetings,

    David das Neves

    Technology Specialist - Consulting Services
    Computacenter AG & Co. oHG - München

    Blog    

    Caution: This post may contain errors.

    Freitag, 21. August 2015 13:16
  • Das sieht deutlich besser aus! Erst mal vielen Dank bis hierhin. Er gibt mir fünf Mal (fünf DFS Stämme) die Rückmeldung "Done processing this command." Jedoch befinden sich in der XML nur die Pfade von einem Stamm. Hast Du noch eine Idee?
    Freitag, 21. August 2015 13:23
  • Das sieht deutlich besser aus! Erst mal vielen Dank bis hierhin. Er gibt mir fünf Mal (fünf DFS Stämme) die Rückmeldung "Done processing this command." Jedoch befinden sich in der XML nur die Pfade von einem Stamm. Hast Du noch eine Idee?

    Ja das liegt daran, da du die Dateien immer überschreibst.

    So haben wir es dann für jeden Namespace separat:

    $DFSRoots = (Get-DFSNRoot).Path
    $Date = Get-Date -Format yyy-MM-dd
    ForEach ($Root in $DFSRoots)
        { 
           dfsutil root export $($Root) $("D:\DFSBCK-$Root-$Date.xml")
        }


    Greetings,

    David das Neves

    Technology Specialist - Consulting Services
    Computacenter AG & Co. oHG - München

    Blog    

    Caution: This post may contain errors.

    Freitag, 21. August 2015 13:59