lunches专题

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 25 Additional random tips

25.2 Operators: -as, -is, -replace, -join, -split, -in, -contains 25.2.1 -as and -is The -as operator produces a new object in an attempt to convert an existing object into a different type. 如果我

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 25 Additional random tips

25.2 Operators: -as, -is, -replace, -join, -split, -in, -contains 25.2.1 -as and -is The -as operator produces a new object in an attempt to convert an existing object into a different type. 如果我

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 22 Improving your script

22.1 Starting point 此段脚本和之前的区别是将 Format-Table 改成了 Select-Object 。因为我们认为如果一个脚本输出的结果的格式是预定义好的,这样会不太好。假设有个人想要将结果输出到csv文件中,脚本输出的却是格式化的表格,这样就不太好了。所以我们应该给用户权限来自定义输出的格式。如上脚本可以这样: PS C:\> .\Get-DiskInvento

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 22 Improving your script

22.1 Starting point 此段脚本和之前的区别是将 Format-Table 改成了 Select-Object 。因为我们认为如果一个脚本输出的结果的格式是预定义好的,这样会不太好。假设有个人想要将结果输出到csv文件中,脚本输出的却是格式化的表格,这样就不太好了。所以我们应该给用户权限来自定义输出的格式。如上脚本可以这样: PS C:\> .\Get-DiskInvento

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 21 You call this scriptin

21.3 Parameterizing commands 我们编写了一个叫 Get-DiskInventory.ps1 的程序,内容如下: Get-WmiObject -class Win32_LogicalDisk -computername localhost -filter "drivetype=3" |Sort-Object -property DeviceID |Format-Ta

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 21 You call this scriptin

21.3 Parameterizing commands 我们编写了一个叫 Get-DiskInventory.ps1 的程序,内容如下: Get-WmiObject -class Win32_LogicalDisk -computername localhost -filter "drivetype=3" |Sort-Object -property DeviceID |Format-Ta

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 19 Input and output

19.2 Read-Host Read-Host 用来收集用户输入 PS C:\> read-host "Enter a computer name"Enter a computer name: SERVER-R2SERVER-R2 我们可以将输入的值保存到变量中: PS C:\> $computername = read-host "Enter a computer name"En

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 19 Input and output

19.2 Read-Host Read-Host 用来收集用户输入 PS C:\> read-host "Enter a computer name"Enter a computer name: SERVER-R2SERVER-R2 我们可以将输入的值保存到变量中: PS C:\> $computername = read-host "Enter a computer name"En

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 18 Variables

18.2 Storing values in variables Everything in PowerShell—and we do mean everything—is treated as an object. 要查看对象的方法和属性,我们可以使用Gm命令 PowerShell允许我们将值保存到变量中,如 PS C:\> $var = "SERVER-R2" 其中的 $ 不是变

《Learn Windows PowerShell in a Month of Lunches Third Edition》读书笔记—CHAPTER 18 Variables

18.2 Storing values in variables Everything in PowerShell—and we do mean everything—is treated as an object. 要查看对象的方法和属性,我们可以使用Gm命令 PowerShell允许我们将值保存到变量中,如 PS C:\> $var = "SERVER-R2" 其中的 $ 不是变