Hp Scripting Tools for Windows PowerShell Uživatelský manuál Strana 20

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 25
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 19
Script writing methodology
When deciding to write a script, you generally know what you want to accomplish. One of the
powerful features of PowerShell ISE is that you can build a script piece-by-piece, testing code and
viewing objects to get a better understanding how to accomplish what you want to do.
Here is a typical process you might want to use for creating PowerShell scripts.
1. Determine what type of data you want to get.
2. Execute the appropriate command interactively to retrieve the data.
3. After viewing the command results, decide what part of the object you are interested in.
4. Determine iLOs or other sources of information that will drive the process.
5. Create the main processing loop.
6. Summarize or output the data in the desired format.
If there are many steps, repeat the process until all of the requirements of the data collection or
setting have been completed.
As demonstrated in the preceding examples, consider using .CSV files to drive input when there
are multiple inputs to act on. It is also possible to use XML files and import data from a source that
generates or maintains XML type data, such as a database. To get the same object from an XML
file, you could create it by using the Export-Clixml command to see what it looks like. The
same input3.csv data that is exported to an XML file looks like this:
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.Management.Automation.PSCustomObject</T>
<T>System.Object</T>
</TN>
<MS>
<S N="Server">192.168.1.9</S>
<S N="Username">admin</S>
<S N="Password">admin123</S>
</MS>
</Obj>
<Obj RefId="1">
<TNRef RefId="0" />
<MS>
<S N="Server">192.168.1.14</S>
<S N="Username">admin</S>
<S N="Password">admin123</S>
</MS>
</Obj>
</Objs>
20 HP Scripting Tools for Windows PowerShell cmdlets
Zobrazit stránku 19
1 2 ... 15 16 17 18 19 20 21 22 23 24 25

Komentáře k této Příručce

Žádné komentáře