From d83ef880d7200ca38f61f73e82a6ac43919f1129 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Thu, 25 Jan 2018 16:13:43 -0600 Subject: [PATCH 01/45] address example formatting Also includes some update to wording that I'll expand on in PR. --- .../Import-Csv.md | 202 ++++++++++-------- 1 file changed, 118 insertions(+), 84 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index e7512951baa7..e2c271731a4f 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -47,18 +47,31 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file PS C:\> Get-Process | Export-Csv processes.csv PS C:\> $P = Import-Csv processes.csv PS C:\> $P | Get-Member -PS C:\> $P | Format-Table -TypeName: CSV:System.Diagnostics.Process + + + TypeName: CSV:System.Diagnostics.Process Name MemberType Definition ---- ---------- ---------- -Equals Method System.Boolean Equals(Object obj) -GetHashCode Method System.Int32 GetHashCode() -GetType Method System.Type GetType() -ToString Method System.String ToString() -BasePriority NoteProperty System.String BasePriority=8 -Company NoteProperty System.String Company=Microsoft Corporation +Equals Method bool Equals(System.Object obj) +GetHashCode Method int GetHashCode() +GetType Method type GetType() +ToString Method string ToString() +BasePriority NoteProperty string BasePriority=8 +Company NoteProperty string Company=Microsoft Corporation +... +PS C:\> $P | Format-Table + +Name SI Handles VM WS PM NPM Path +---- -- ------- -- -- -- --- ---- +ApplicationFrameHost 4 407 2199293489152 15884288 15151104 23792 C:\WINDOWS\system32\ApplicationFrameHost.exe ... +wininit 0 157 2199112204288 4591616 1630208 10376 +winlogon 4 233 2199125549056 7659520 2826240 10992 C:\WINDOWS\System32\WinLogon.exe +WinStore.App 4 846 873435136 33652736 26607616 55432 C:\Program Files\WindowsApps\Microsoft.WindowsStore_11712.1001.13.0_x64__8weky... +WmiPrvSE 0 201 2199100219392 8830976 3297280 10632 C:\WINDOWS\system32\wbem\wmiprvse.exe +WmiPrvSE 0 407 2199157727232 18509824 12922880 16624 C:\WINDOWS\system32\wbem\wmiprvse.exe +WUDFHost 0 834 2199310204928 51945472 87441408 24984 C:\Windows\System32\WUDFHost.exe ``` This example shows how to export and then import a CSV file of process objects. @@ -89,19 +102,20 @@ When importing, the **Import-Csv** file uses the *Delimiter* parameter to indica ### Example 3: Specify the current culture for the delimiter ``` +PS C:\> Get-Process | Export-Csv processes.csv -UseCulture PS C:\> $P = Import-Csv processes.csv -UseCulture -PS C:\> (Get-Culture).textinfo.listseparator +PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` This example shows how to use the *UseCulture* parameter of the **Import-Csv** cmdlet. -The first command imports the objects in the Processes.csv file into the $P variable. -It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. +In this example the processes are exported to a file that uses the culture as a delimiter. +The next command imports the objects in the Processes.csv file into the `$P` variable. It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. -The second command displays the list separator for the current culture. -It uses the Get-Culture cmdlet to get the current culture. +The second command displays the list separator for the current culture. It uses the Get-Culture cmdlet to get the current culture. It uses the dot (.) method to get the TextInfo property of the current culture and the ListSeparator property of the object in TextInfo. + In this example, the command returns a comma. ### Example 4: Change property names in an imported object @@ -117,23 +131,24 @@ PS C:\> $A > jobs.csv PS C:\> $J = Import-Csv jobs.csv -Header $Header PS C:\> $J -MoreData : True -StatusMessage : -Location : localhost -Command : get-process -State : Running -Finished : System.Threading.ManualResetEvent -InstanceId : 135bdd25-40d6-4a20-bd68-05282a59abd6 -SessionId : 1 -Name : Job1 -ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] -Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] -Verbose : System.Management.Automation.PSDataCollection`1[System.String] -Debug : System.Management.Automation.PSDataCollection`1[System.String] -Warning : System.Management.Automation.PSDataCollection`1[System.String] -StateChanged : + +MoreData : Running +StatusMessage : True +Location : +Command : localhost +State : Get-Process +Finished : Running +InstanceId : System.Threading.ManualResetEvent +SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f +Name : 3 +ChildJobs : Job3 +Output : System.Collections.Generic.List`1[System.Management.Automation.Job] +Error : 2018-01-25 3:17:34 PM +Progress : +Verbose : BackgroundJob +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] ``` This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. @@ -156,31 +171,40 @@ The resulting object has MoreData and State properties, as shown in the command ### Example 5: Create a custom object using a CSV file ``` PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, -about_Core_Commands113220,about_Data_Section… PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle +113207,about_Aliases +113208,about_Arithmetic_Operators +113209,about_Arrays +113210,about_Assignment_Operators +113212,about_Automatic_Variables +113213,about_Break +113214,about_Command_Precedence +113215,about_Command_Syntax +144309,about_Comment_Based_Help +113216,about_CommonParameters +113217,about_Comparison_Operators +113218,about_Continue +113219,about_Core_Commands +113220,about_Data_Section +PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle PS C:\> $A | Get-Member + + TypeName: System.Management.Automation.PSCustomObject -Name MemberType Definition ----- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String -TopicTitle=about_Aliases PS C:\> $A | Where-Object TopicTitle -Like "*alias*" -LinkID TopicTitle ------- ---------- -113207 about_Aliases -113432 Alias Provider -113296 Export-Alias -113306 Get-Alias -113339 Import-Alias -113352 New-Alias -113390 Set-Alias + +Name MemberType Definition +---- ---------- ---------- +Equals Method bool Equals(System.Object obj) +GetHashCode Method int GetHashCode() +GetType Method type GetType() +ToString Method string ToString() +LinkID NoteProperty string LinkID=113207 +TopicTitle NoteProperty string TopicTitle=about_Aliases + +PS C:\> $A | Where-Object TopicTitle -Like "*alias*" + +LinkID TopicTitle +------ ---------- +113207 about_Aliases ``` This example shows how to create a custom object in Windows PowerShell by using a CSV file. @@ -205,17 +229,29 @@ The Where-Object command uses the new simplified command format that does not re ### Example 6: Import a CSV that is missing a value ``` PS C:\> Get-Content "\\Server2\c$\Test\Projects.csv" -ProjectID, ProjectName,,Completed, Inventory, Redmond, True440, , FarEast, True, Marketing, Europe, False PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. -ProjectID ProjectName H1 Completed ---------- ----------- -- --------- -13 Inventory Redmond True -440 FarEast True -469 Marketing Europe False PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 -RedmondFarEastEurope +ProjectID,ProjectName,,Completed +13,Inventory,Redmond,True +440,,FarEast,True +469,Marketing,Europe,False +PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. + +ProjectID ProjectName H1 Completed +--------- ----------- -- --------- +13 Inventory Redmond True +440 FarEast True +469 Marketing Europe False + + +PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +Redmond +FarEast +Europe ``` -This example shows how the **Import-Csv** cmdlet in Windows PowerShell 3.0 responds when the header row in a CSV file includes a null or empty value. +This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds when the header row in a CSV file includes a null or empty value. + **Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. @@ -233,9 +269,10 @@ The third command uses the dot method to get the value of the H1 property of the ### -Delimiter Specifies the delimiter that separates the property values in the CSV file. -The default is a comma (,). -Enter a character, such as a colon (:). -To specify a semicolon (;), enclose it in quotation marks. + +- The default is a comma (,). +- Enter a character, such as a colon (:). +- To specify a semicolon (;), enclose it in quotation marks. If you specify a character other than the actual string delimiter in the file, **Import-Csv** cannot create objects from the CSV strings. Instead, it returns the strings. @@ -243,7 +280,7 @@ Instead, it returns the strings. ```yaml Type: Char Parameter Sets: Delimiter -Aliases: +Aliases: Required: False Position: 1 @@ -272,7 +309,7 @@ This parameter was introduced in Windows PowerShell 3.0. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Accepted values: Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, OEM Required: False @@ -283,22 +320,20 @@ Accept wildcard characters: False ``` ### -Header -Specifies an alternate column header row for the imported file. -The column header determines the names of the properties of the object that **Import-Csv** creates. +Specifies an alternate column header row for the imported file. The column header determines the names of the properties of the object that **Import-Csv** creates. -Enter a comma-separated list of the column headers. -Enclose each item in quotation marks (single or double). -Do not enclose the header string in quotation marks. -If you enter fewer column headers than there are columns, the remaining columns will have no header. -If you enter more headers than there are columns, the extra headers are ignored. +- Enter a comma-separated list of the column headers. +- Enclose each item in quotation marks (single or double). +- Do not enclose the header string in quotation marks. +- If you enter fewer column headers than there are columns, the remaining columns will have no header. +- If you enter more headers than there are columns, the extra headers are ignored. -When using the *Header* parameter, delete the original header row from the CSV file. -Otherwise, **Import-Csv** creates an extra object from the items in the header row. +When using the *Header* parameter, delete the original header row from the CSV file. Otherwise, **Import-Csv** creates an extra object from the items in the header row. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -308,10 +343,8 @@ Accept wildcard characters: False ``` ### -LiteralPath -Specifies the path to the CSV file to import. -Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. -No characters are interpreted as wildcards. -If the path includes escape characters, enclose it in single quotation marks. +Specifies the path to the CSV file to import. Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. +No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. ```yaml @@ -333,7 +366,7 @@ You can also pipe a path to **Import-Csv**. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: 0 @@ -344,7 +377,7 @@ Accept wildcard characters: False ### -UseCulture Indicates that this cmdlet uses the list separator for the current culture as the item delimiter. -The default is a comma (,). +The default is based on the culture settings of the Operating System (e.g. en-US culture will return a comma (,) by default). To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-Csv cannot create objects from the CSV strings. @@ -353,7 +386,7 @@ Instead, it returns the strings. ```yaml Type: SwitchParameter Parameter Sets: UseCulture -Aliases: +Aliases: Required: True Position: Named @@ -390,3 +423,4 @@ This cmdlet returns the objects described by the content in the CSV file. [Export-Csv](Export-Csv.md) +[Get-Culture](Get-Culture.md) \ No newline at end of file From b7b5c0397da59954869124351d18f190a0061f8b Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Thu, 25 Jan 2018 16:14:09 -0600 Subject: [PATCH 02/45] Start on update formatting for 3.0 doc --- .../Import-Csv.md | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 29830be15be6..cd8737fc0c23 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -9,8 +9,10 @@ title: Import-Csv --- # Import-Csv + ## SYNOPSIS Creates table-like custom objects from the items in a CSV file. + ## SYNTAX ### Delimiter (Default) @@ -134,9 +136,9 @@ This example shows how to use the Header parameter of Import-Csv to change the n ``` The first command uses the Get-Content cmdlet to get the Links.csv file. PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, +113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, +about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, +about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, about_Core_Commands113220,about_Data_Section… The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the **Header** parameter to specify **LinkId** and **TopicTitle** as property names for the new custom objects. The command saves the imported objects in the $a variable. @@ -147,13 +149,13 @@ PS C:\> $a | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String +Equals Method bool +Equals(System.Object obj) +GetHashCode Method int +GetHashCode()GetType Method type +GetType()ToString Method string +ToString()LinkID NoteProperty System.String +LinkID=113207TopicTitle NoteProperty System.String TopicTitle=about_Aliases This command shows that you can use the custom object like you would any object in Windows PowerShell.The command pipes the custom objects in the $a variable to the **Where-Object** cmdlet, which gets only objects with a **TopicTitle** property that includes "alias".The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. @@ -178,7 +180,7 @@ ProjectID, ProjectName,,Completed13, Inventory, Redmond, True440, , FarEast, Tru The second command uses the **Import-Csv** cmdlet to import the Projects.csv file.The output shows that Import-Csv generates a warning and substitutes a default name, H1, for the missing header row value. H1 is also used for the name of the object property. PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. ProjectID ProjectName H1 Completed --------- ----------- -- --------- 13 Inventory Redmond True @@ -207,7 +209,7 @@ Instead, it returns the strings. ```yaml Type: Char Parameter Sets: Delimiter -Aliases: +Aliases: Required: False Position: 2 @@ -226,7 +228,7 @@ This parameter is introduced in Windows PowerShell 3.0. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -251,7 +253,7 @@ Otherwise, Import-Csv creates an extra object from the items in the header row. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -267,7 +269,7 @@ You can also pipe a path to Import-Csv. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: 1 @@ -287,7 +289,7 @@ Instead, it returns the strings. ```yaml Type: SwitchParameter Parameter Sets: UseCulture -Aliases: +Aliases: Required: True Position: Named From cce3269503c8cd6f011be0fe7b401cbf58effd40 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 18:44:59 -0600 Subject: [PATCH 03/45] More formatting --- .../Import-Csv.md | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index e2c271731a4f..ae9dd2fd6f1e 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -111,7 +111,7 @@ PS C:\> (Get-Culture).TextInfo.ListSeparator This example shows how to use the *UseCulture* parameter of the **Import-Csv** cmdlet. In this example the processes are exported to a file that uses the culture as a delimiter. -The next command imports the objects in the Processes.csv file into the `$P` variable. It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. +The next command imports the objects in the Processes.csv file into the $P variable. It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. The second command displays the list separator for the current culture. It uses the Get-Culture cmdlet to get the current culture. It uses the dot (.) method to get the TextInfo property of the current culture and the ListSeparator property of the object in TextInfo. @@ -270,9 +270,11 @@ The third command uses the dot method to get the value of the H1 property of the ### -Delimiter Specifies the delimiter that separates the property values in the CSV file. -- The default is a comma (,). -- Enter a character, such as a colon (:). -- To specify a semicolon (;), enclose it in quotation marks. +The default is a comma (,). + +Enter a character, such as a colon (:). + +To specify a semicolon (;), enclose it in quotation marks. If you specify a character other than the actual string delimiter in the file, **Import-Csv** cannot create objects from the CSV strings. Instead, it returns the strings. @@ -322,11 +324,15 @@ Accept wildcard characters: False ### -Header Specifies an alternate column header row for the imported file. The column header determines the names of the properties of the object that **Import-Csv** creates. -- Enter a comma-separated list of the column headers. -- Enclose each item in quotation marks (single or double). -- Do not enclose the header string in quotation marks. -- If you enter fewer column headers than there are columns, the remaining columns will have no header. -- If you enter more headers than there are columns, the extra headers are ignored. +Enter a comma-separated list of the column headers. + +Enclose each item in quotation marks (single or double). + +Do not enclose the header string in quotation marks. + +If you enter fewer column headers than there are columns, the remaining columns will have no header. + +If you enter more headers than there are columns, the extra headers are ignored. When using the *Header* parameter, delete the original header row from the CSV file. Otherwise, **Import-Csv** creates an extra object from the items in the header row. @@ -343,7 +349,8 @@ Accept wildcard characters: False ``` ### -LiteralPath -Specifies the path to the CSV file to import. Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. +Specifies the path to the CSV file to import. +Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. From 8d7f515a7a817e9f10978b1e6367ba07f9ffa889 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 18:45:32 -0600 Subject: [PATCH 04/45] Correcting examples and format of them. --- .../Import-Csv.md | 142 +++++++++++------- 1 file changed, 86 insertions(+), 56 deletions(-) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index e7512951baa7..6a196629045c 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -90,7 +90,7 @@ When importing, the **Import-Csv** file uses the *Delimiter* parameter to indica ### Example 3: Specify the current culture for the delimiter ``` PS C:\> $P = Import-Csv processes.csv -UseCulture -PS C:\> (Get-Culture).textinfo.listseparator +PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` @@ -117,23 +117,24 @@ PS C:\> $A > jobs.csv PS C:\> $J = Import-Csv jobs.csv -Header $Header PS C:\> $J -MoreData : True -StatusMessage : -Location : localhost -Command : get-process -State : Running -Finished : System.Threading.ManualResetEvent -InstanceId : 135bdd25-40d6-4a20-bd68-05282a59abd6 -SessionId : 1 -Name : Job1 -ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] -Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] -Verbose : System.Management.Automation.PSDataCollection`1[System.String] -Debug : System.Management.Automation.PSDataCollection`1[System.String] -Warning : System.Management.Automation.PSDataCollection`1[System.String] -StateChanged : + +MoreData : Running +StatusMessage : True +Location : +Command : localhost +State : Get-Process +Finished : Running +InstanceId : System.Threading.ManualResetEvent +SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f +Name : 3 +ChildJobs : Job3 +Output : System.Collections.Generic.List`1[System.Management.Automation.Job] +Error : 2018-01-25 3:17:34 PM +Progress : +Verbose : BackgroundJob +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] ``` This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. @@ -156,31 +157,40 @@ The resulting object has MoreData and State properties, as shown in the command ### Example 5: Create a custom object using a CSV file ``` PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, -about_Core_Commands113220,about_Data_Section… PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle +113207,about_Aliases +113208,about_Arithmetic_Operators +113209,about_Arrays +113210,about_Assignment_Operators +113212,about_Automatic_Variables +113213,about_Break +113214,about_Command_Precedence +113215,about_Command_Syntax +144309,about_Comment_Based_Help +113216,about_CommonParameters +113217,about_Comparison_Operators +113218,about_Continue +113219,about_Core_Commands +113220,about_Data_Section +PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle PS C:\> $A | Get-Member + + TypeName: System.Management.Automation.PSCustomObject -Name MemberType Definition ----- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String -TopicTitle=about_Aliases PS C:\> $A | Where-Object TopicTitle -Like "*alias*" -LinkID TopicTitle ------- ---------- -113207 about_Aliases -113432 Alias Provider -113296 Export-Alias -113306 Get-Alias -113339 Import-Alias -113352 New-Alias -113390 Set-Alias + +Name MemberType Definition +---- ---------- ---------- +Equals Method bool Equals(System.Object obj) +GetHashCode Method int GetHashCode() +GetType Method type GetType() +ToString Method string ToString() +LinkID NoteProperty string LinkID=113207 +TopicTitle NoteProperty string TopicTitle=about_Aliases + +PS C:\> $A | Where-Object TopicTitle -Like "*alias*" + +LinkID TopicTitle +------ ---------- +113207 about_Aliases ``` This example shows how to create a custom object in Windows PowerShell by using a CSV file. @@ -205,17 +215,29 @@ The Where-Object command uses the new simplified command format that does not re ### Example 6: Import a CSV that is missing a value ``` PS C:\> Get-Content "\\Server2\c$\Test\Projects.csv" -ProjectID, ProjectName,,Completed, Inventory, Redmond, True440, , FarEast, True, Marketing, Europe, False PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. -ProjectID ProjectName H1 Completed ---------- ----------- -- --------- -13 Inventory Redmond True -440 FarEast True -469 Marketing Europe False PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 -RedmondFarEastEurope +ProjectID,ProjectName,,Completed +13,Inventory,Redmond,True +440,,FarEast,True +469,Marketing,Europe,False +PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. + +ProjectID ProjectName H1 Completed +--------- ----------- -- --------- +13 Inventory Redmond True +440 FarEast True +469 Marketing Europe False + + +PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +Redmond +FarEast +Europe ``` -This example shows how the **Import-Csv** cmdlet in Windows PowerShell 3.0 responds when the header row in a CSV file includes a null or empty value. +This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds when the header row in a CSV file includes a null or empty value. + **Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. @@ -233,8 +255,11 @@ The third command uses the dot method to get the value of the H1 property of the ### -Delimiter Specifies the delimiter that separates the property values in the CSV file. + The default is a comma (,). + Enter a character, such as a colon (:). + To specify a semicolon (;), enclose it in quotation marks. If you specify a character other than the actual string delimiter in the file, **Import-Csv** cannot create objects from the CSV strings. @@ -243,7 +268,7 @@ Instead, it returns the strings. ```yaml Type: Char Parameter Sets: Delimiter -Aliases: +Aliases: Required: False Position: 1 @@ -272,7 +297,7 @@ This parameter was introduced in Windows PowerShell 3.0. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Accepted values: Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, OEM Required: False @@ -287,9 +312,13 @@ Specifies an alternate column header row for the imported file. The column header determines the names of the properties of the object that **Import-Csv** creates. Enter a comma-separated list of the column headers. + Enclose each item in quotation marks (single or double). + Do not enclose the header string in quotation marks. + If you enter fewer column headers than there are columns, the remaining columns will have no header. + If you enter more headers than there are columns, the extra headers are ignored. When using the *Header* parameter, delete the original header row from the CSV file. @@ -298,7 +327,7 @@ Otherwise, **Import-Csv** creates an extra object from the items in the header r ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -311,6 +340,7 @@ Accept wildcard characters: False Specifies the path to the CSV file to import. Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. + If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. @@ -333,7 +363,7 @@ You can also pipe a path to **Import-Csv**. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: 0 @@ -344,7 +374,7 @@ Accept wildcard characters: False ### -UseCulture Indicates that this cmdlet uses the list separator for the current culture as the item delimiter. -The default is a comma (,). +The default is based on the culture settings of the Operating System (e.g. en-US culture will return a comma (,) by default). To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-Csv cannot create objects from the CSV strings. @@ -353,7 +383,7 @@ Instead, it returns the strings. ```yaml Type: SwitchParameter Parameter Sets: UseCulture -Aliases: +Aliases: Required: True Position: Named From b0aa8304727519598c95ea04b9d9912b529228c9 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:23:55 -0600 Subject: [PATCH 05/45] 3.0 update format example 1 --- .../Import-Csv.md | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index cd8737fc0c23..266944eb7cc0 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -43,14 +43,9 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file ### Example 1 ``` -This example shows how to export and then import a CSV file of objects.The first command uses the Get-Process cmdlet to get the process on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-CSV cmdlet, which exports the process objects to the Processes.csv file in the current directory. -PS C:\> get-process | export-csv processes.csv - -The second command uses the Import-Csv cmdlet to import the processes in the Import-Csv file. Then it saves the resulting process objects in the $p variable. -PS C:\> $p = Import-Csv processes.csv - -The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlets. The result shows that they are CSV:System.Diagnostic.Process objects, not the System.Diagnostic.Process objects that Get-Process returns.Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted.To display the objects, use the formatting cmdlets, such as Format-Table and Format-List, or pipe the objects to Out-GridView. -PS C:\> $p | get-member +PS C:\> Get-Process | Export-Csv processes.csv +PS C:\> $P = Import-Csv processes.csv +PS C:\> $P | Get-Member TypeName: CSV:System.Diagnostics.Process Name MemberType Definition ---- ---------- ---------- @@ -61,10 +56,31 @@ ToString Method System.String ToString() BasePriority NoteProperty System.String BasePriority=8 Company NoteProperty System.String Company=Microsoft Corporation ... -PS C:\> $p | out-gridview -``` +PS C:\> $P | Format-Table +Name SI Handles VM WS PM NPM Path +---- -- ------- -- -- -- --- ---- +ApplicationFrameHost 4 407 2199293489152 15884288 15151104 23792 C:\WINDOWS\system32\ApplicationFrameHost.exe +... +wininit 0 157 2199112204288 4591616 1630208 10376 +winlogon 4 233 2199125549056 7659520 2826240 10992 C:\WINDOWS\System32\WinLogon.exe +WinStore.App 4 846 873435136 33652736 26607616 55432 C:\Program Files\WindowsApps\Microsoft.WindowsStore_11712.1001.13.0_x64__8weky... +WmiPrvSE 0 201 2199100219392 8830976 3297280 10632 C:\WINDOWS\system32\wbem\wmiprvse.exe +WmiPrvSE 0 407 2199157727232 18509824 12922880 16624 C:\WINDOWS\system32\wbem\wmiprvse.exe +WUDFHost 0 834 2199310204928 51945472 87441408 24984 C:\Windows\System32\WUDFHost.exe +``` This example shows how to export and then import a CSV file of objects. + +The first command uses the Get-Process cmdlet to get the process on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-CSV cmdlet, which exports the process objects to the Processes.csv file in the current directory. + +The second command uses the **Import-Csv** cmdlet to import the processes in the **Import-Csv** file. Then it saves the resulting process objects in the $P variable. + +The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlets. The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that **Get-Process** returns. + +Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted. + +To display the objects, use the formatting cmdlets, such as Format-Table and Format-List, or pipe the objects to Out-GridView. + ### Example 2 ``` PS C:\> get-process | export-csv processes.csv -Delimiter : From 1f0a2060a0b4f900a982617523b6023aef398dc7 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:25:29 -0600 Subject: [PATCH 06/45] 3.0 update to example 2 --- .../3.0/Microsoft.PowerShell.Utility/Import-Csv.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 266944eb7cc0..9473e22f5d92 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -83,24 +83,25 @@ To display the objects, use the formatting cmdlets, such as Format-Table and For ### Example 2 ``` -PS C:\> get-process | export-csv processes.csv -Delimiter : -PS C:\> $p = Import-Csv processes.csv -Delimiter : +PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : +PS C:\> $P = Import-Csv processes.csv -Delimiter : ``` -This example shows how to use the *Delimiter* parameter of the Import-Csv cmdlet. +This example shows how to use the *Delimiter* parameter of the **Import-Csv** cmdlet. In this example, the processes are exported to a file that uses a colon (:) as a delimiter. -When importing, the Import-Csv file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. +When importing, the **Import-Csv** file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. + ### Example 3 ``` -PS C:\> $p = Import-Csv processes.csv -UseCulture +PS C:\> $P = Import-Csv processes.csv -UseCulture PS C:\> (get-culture).textinfo.listseparator , ``` This example shows how to use the *UseCulture* parameter of the Import-Csv cmdlet. -The first command imports the objects in the Processes.csv file into the $p variable. +The first command imports the objects in the Processes.csv file into the $P variable. It uses the *UseCulture* parameter to direct Import-Csv to use the list separator defined for the current culture. The second command displays the list separator for the current culture. From 8eb0ab1a5d2f7db7ec6f9e3a9e95dbf1192e87d7 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:39:09 -0600 Subject: [PATCH 07/45] 3.0 update example 4 --- .../Import-Csv.md | 81 ++++++++++--------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 9473e22f5d92..a610a4811fdc 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -94,61 +94,68 @@ When importing, the **Import-Csv** file uses the *Delimiter* parameter to indica ### Example 3 ``` +PS C:\> Get-Process | Export-Csv processes.csv -UseCulture PS C:\> $P = Import-Csv processes.csv -UseCulture -PS C:\> (get-culture).textinfo.listseparator +PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` -This example shows how to use the *UseCulture* parameter of the Import-Csv cmdlet. +This example shows how to use the *UseCulture* parameter of the **Import-Csv** cmdlet. -The first command imports the objects in the Processes.csv file into the $P variable. -It uses the *UseCulture* parameter to direct Import-Csv to use the list separator defined for the current culture. +In this example the processes are exported to a file that uses the culture as a delimiter. +The next command imports the objects in the Processes.csv file into the $P variable. +It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. -The second command displays the list separator for the current culture. -It uses the Get-Culture cmdlet to get the current culture. +The second command displays the list separator for the current culture. It uses the Get-Culture cmdlet to get the current culture. It uses the dot (.) method to get the TextInfo property of the current culture and the ListSeparator property of the object in TextInfo. + In this example, the command returns a comma. + ### Example 4 ``` +PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv jobs.csv +PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" + +# Delete header from file + +PS C:\> $A = (Get-Content jobs.csv) +PS C:\> $A = $A[0], $A[2..($A.count - 1)] +PS C:\> $A > jobs.csv +PS C:\> $J = Import-Csv jobs.csv -Header $Header +PS C:\> $J + + +MoreData : Running +StatusMessage : True +Location : +Command : localhost +State : Get-Process +Finished : Running +InstanceId : System.Threading.ManualResetEvent +SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f +Name : 3 +ChildJobs : Job3 +Output : System.Collections.Generic.List`1[System.Management.Automation.Job] +Error : 2018-01-25 3:17:34 PM +Progress : +Verbose : BackgroundJob +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +``` + +This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. + The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-CSV cmdlet, which converts the job object to CSV format. An assignment operator (=) saves the resulting CSV in the Jobs.csv file. -PS C:\> start-job -scriptblock { get-process } | export-csv jobs.csv -The second command saves a header in the $header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". -PS C:\> $header = "MoreData","StatusMessage","Location","Command","State","Finished","InstanceId","SessionId","Name","ChildJobs","Output","Error","Progress","Verbose","Debug","Warning","StateChanged" +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". The next three commands delete the original header (the second line) from the Jobs.csv file. -PS C:\> # Delete header from file - -PS C:\> $a = (get-content jobs.csv) -PS C:\> $a = $a[0], $a[2..($a.count - 1)] -PS C:\> $a > jobs.csv -The sixth command uses the Import-Csv cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the Header parameter to submit the alternate header. The results are stored in the $j variable. -PS C:\> $j = Import-Csv jobs.csv -header $header +The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $j variable. The seventh command displays the object in the $j variable. The resulting object has "MoreData" and "State" properties, as shown in the command output. -PS C:\> $j - -MoreData : True -StatusMessage : -Location : localhost -Command : get-process -State : Running -Finished : System.Threading.ManualResetEvent -InstanceId : 135bdd25-40d6-4a20-bd68-05282a59abd6 -SessionId : 1 -Name : Job1 -ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] -Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] -Verbose : System.Management.Automation.PSDataCollection`1[System.String] -Debug : System.Management.Automation.PSDataCollection`1[System.String] -Warning : System.Management.Automation.PSDataCollection`1[System.String] -StateChanged : -``` -This example shows how to use the Header parameter of Import-Csv to change the names of properties in the resulting imported object. ### Example 5 ``` The first command uses the Get-Content cmdlet to get the Links.csv file. From 83b7e9b260ba4f5fbd6dc27fb6c77d3583d998ca Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:39:54 -0600 Subject: [PATCH 08/45] 4.0 update example 1-4 --- .../Import-Csv.md | 135 +++++++++--------- 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 0138b6cbd47e..d6f8a744e824 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -47,11 +47,11 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file This example shows how to export and then import a CSV file of objects.The first command uses the Get-Process cmdlet to get the process on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-CSV cmdlet, which exports the process objects to the Processes.csv file in the current directory. PS C:\> get-process | export-csv processes.csv -The second command uses the Import-Csv cmdlet to import the processes in the Import-Csv file. Then it saves the resulting process objects in the $p variable. -PS C:\> $p = Import-Csv processes.csv +The second command uses the Import-Csv cmdlet to import the processes in the Import-Csv file. Then it saves the resulting process objects in the $P variable. +PS C:\> $P = Import-Csv processes.csv The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlets. The result shows that they are CSV:System.Diagnostic.Process objects, not the System.Diagnostic.Process objects that Get-Process returns.Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted.To display the objects, use the formatting cmdlets, such as Format-Table and Format-List, or pipe the objects to Out-GridView. -PS C:\> $p | get-member +PS C:\> $P | get-member TypeName: CSV:System.Diagnostics.Process Name MemberType Definition ---- ---------- ---------- @@ -62,88 +62,93 @@ ToString Method System.String ToString() BasePriority NoteProperty System.String BasePriority=8 Company NoteProperty System.String Company=Microsoft Corporation ... -PS C:\> $p | out-gridview +PS C:\> $P | out-gridview ``` This example shows how to export and then import a CSV file of objects. ### Example 2 ``` -PS C:\> get-process | export-csv processes.csv -Delimiter : -PS C:\> $p = Import-Csv processes.csv -Delimiter : +PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : +PS C:\> $P = Import-Csv processes.csv -Delimiter : ``` -This example shows how to use the *Delimiter* parameter of the Import-Csv cmdlet. +This example shows how to use the *Delimiter* parameter of the **Import-Csv** cmdlet. In this example, the processes are exported to a file that uses a colon (:) as a delimiter. -When importing, the Import-Csv file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. +When importing, the **Import-Csv** file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. ### Example 3 ``` -PS C:\> $p = Import-Csv processes.csv -UseCulture -PS C:\> (get-culture).textinfo.listseparator +PS C:\> Get-Process | Export-Csv processes.csv -UseCulture +PS C:\> $P = Import-Csv processes.csv -UseCulture +PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` This example shows how to use the *UseCulture* parameter of the Import-Csv cmdlet. -The first command imports the objects in the Processes.csv file into the $p variable. -It uses the *UseCulture* parameter to direct Import-Csv to use the list separator defined for the current culture. +In this example the processes are exported to a file that uses the culture as a delimiter. +The next command imports the objects in the Processes.csv file into the $P variable. +It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. -The second command displays the list separator for the current culture. -It uses the Get-Culture cmdlet to get the current culture. +The second command displays the list separator for the current culture. It uses the Get-Culture cmdlet to get the current culture. It uses the dot (.) method to get the TextInfo property of the current culture and the ListSeparator property of the object in TextInfo. + In this example, the command returns a comma. ### Example 4 ``` -The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-CSV cmdlet, which converts the job object to CSV format. An assignment operator (=) saves the resulting CSV in the Jobs.csv file. -PS C:\> start-job -scriptblock { get-process } | export-csv jobs.csv +PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv jobs.csv +PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" + +# Delete header from file + +PS C:\> $A = (Get-Content jobs.csv) +PS C:\> $A = $A[0], $A[2..($A.count - 1)] +PS C:\> $A > jobs.csv +PS C:\> $J = Import-Csv jobs.csv -Header $Header +PS C:\> $J + + +MoreData : Running +StatusMessage : True +Location : +Command : localhost +State : Get-Process +Finished : Running +InstanceId : System.Threading.ManualResetEvent +SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f +Name : 3 +ChildJobs : Job3 +Output : System.Collections.Generic.List`1[System.Management.Automation.Job] +Error : 2018-01-25 3:17:34 PM +Progress : +Verbose : BackgroundJob +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +``` + +This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. -The second command saves a header in the $header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". -PS C:\> $header = "MoreData","StatusMessage","Location","Command","State","Finished","InstanceId","SessionId","Name","ChildJobs","Output","Error","Progress","Verbose","Debug","Warning","StateChanged" +The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-CSV cmdlet, which converts the job object to CSV format. + +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". The next three commands delete the original header (the second line) from the Jobs.csv file. -PS C:\> # Delete header from file - -PS C:\> $a = (get-content jobs.csv) -PS C:\> $a = $a[0], $a[2..($a.count - 1)] -PS C:\> $a > jobs.csv - -The sixth command uses the Import-Csv cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the Header parameter to submit the alternate header. The results are stored in the $j variable. -PS C:\> $j = Import-Csv jobs.csv -header $header - -The seventh command displays the object in the $j variable. The resulting object has "MoreData" and "State" properties, as shown in the command output. -PS C:\> $j - -MoreData : True -StatusMessage : -Location : localhost -Command : get-process -State : Running -Finished : System.Threading.ManualResetEvent -InstanceId : 135bdd25-40d6-4a20-bd68-05282a59abd6 -SessionId : 1 -Name : Job1 -ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] -Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] -Verbose : System.Management.Automation.PSDataCollection`1[System.String] -Debug : System.Management.Automation.PSDataCollection`1[System.String] -Warning : System.Management.Automation.PSDataCollection`1[System.String] -StateChanged : -``` -This example shows how to use the Header parameter of Import-Csv to change the names of properties in the resulting imported object. +The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. + +The seventh command displays the object in the $J variable. The resulting object has "MoreData" and "State" properties, as shown in the command output. ### Example 5 ``` The first command uses the Get-Content cmdlet to get the Links.csv file. PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, +113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, +about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, +about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, about_Core_Commands113220,about_Data_Section… The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the **Header** parameter to specify **LinkId** and **TopicTitle** as property names for the new custom objects. The command saves the imported objects in the $a variable. @@ -154,13 +159,13 @@ PS C:\> $a | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String +Equals Method bool +Equals(System.Object obj) +GetHashCode Method int +GetHashCode()GetType Method type +GetType()ToString Method string +ToString()LinkID NoteProperty System.String +LinkID=113207TopicTitle NoteProperty System.String TopicTitle=about_Aliases This command shows that you can use the custom object like you would any object in Windows PowerShell.The command pipes the custom objects in the $a variable to the **Where-Object** cmdlet, which gets only objects with a **TopicTitle** property that includes "alias".The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. @@ -186,7 +191,7 @@ ProjectID, ProjectName,,Completed13, Inventory, Redmond, True440, , FarEast, Tru The second command uses the **Import-Csv** cmdlet to import the Projects.csv file.The output shows that Import-Csv generates a warning and substitutes a default name, H1, for the missing header row value. H1 is also used for the name of the object property. PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. ProjectID ProjectName H1 Completed --------- ----------- -- --------- 13 Inventory Redmond True @@ -216,7 +221,7 @@ Instead, it returns the strings. ```yaml Type: Char Parameter Sets: Delimiter -Aliases: +Aliases: Required: False Position: 2 @@ -235,7 +240,7 @@ This parameter is introduced in Windows PowerShell 3.0. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -260,7 +265,7 @@ Otherwise, Import-Csv creates an extra object from the items in the header row. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -276,7 +281,7 @@ You can also pipe a path to Import-Csv. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: 1 @@ -296,7 +301,7 @@ Instead, it returns the strings. ```yaml Type: SwitchParameter Parameter Sets: UseCulture -Aliases: +Aliases: Required: True Position: Named From 9ed5f895905a706b1aa2ccb21a19b7696b6c3cff Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:40:11 -0600 Subject: [PATCH 09/45] 5.0 update example 3 and 4 --- .../Microsoft.PowerShell.Utility/Import-Csv.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 6a196629045c..20aa104f3456 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -89,6 +89,7 @@ When importing, the **Import-Csv** file uses the *Delimiter* parameter to indica ### Example 3: Specify the current culture for the delimiter ``` +PS C:\> Get-Process | Export-Csv processes.csv -UseCulture PS C:\> $P = Import-Csv processes.csv -UseCulture PS C:\> (Get-Culture).TextInfo.ListSeparator , @@ -96,12 +97,13 @@ PS C:\> (Get-Culture).TextInfo.ListSeparator This example shows how to use the *UseCulture* parameter of the **Import-Csv** cmdlet. -The first command imports the objects in the Processes.csv file into the $P variable. +In this example the processes are exported to a file that uses the culture as a delimiter. +The next command imports the objects in the Processes.csv file into the $P variable. It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. -The second command displays the list separator for the current culture. -It uses the Get-Culture cmdlet to get the current culture. +The second command displays the list separator for the current culture. It uses the Get-Culture cmdlet to get the current culture. It uses the dot (.) method to get the TextInfo property of the current culture and the ListSeparator property of the object in TextInfo. + In this example, the command returns a comma. ### Example 4: Change property names in an imported object @@ -142,17 +144,13 @@ This example shows how to use the *Header* parameter of **Import-Csv** to change The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. -The second command saves a header in the $Header variable. -Unlike the default header, this header uses MoreData instead of HasMoreData and State instead of JobStateInfo. +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". The next three commands delete the original header (the second line) from the Jobs.csv file. -The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. -The command uses the *Header* parameter to submit the alternate header. -The results are stored in the $J variable. +The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. -The seventh command displays the object in the $J variable. -The resulting object has MoreData and State properties, as shown in the command output. +The seventh command displays the object in the $J variable. The resulting object has MoreData and State properties, as shown in the command output. ### Example 5: Create a custom object using a CSV file ``` From ee6bd32a4f29536ed0df0f1cab62576f5d46a2f3 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:40:36 -0600 Subject: [PATCH 10/45] 5.1 update example 4 paragraph format --- .../5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index ae9dd2fd6f1e..fa293cb78cf0 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -156,17 +156,13 @@ This example shows how to use the *Header* parameter of **Import-Csv** to change The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. -The second command saves a header in the $Header variable. -Unlike the default header, this header uses MoreData instead of HasMoreData and State instead of JobStateInfo. +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". The next three commands delete the original header (the second line) from the Jobs.csv file. -The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. -The command uses the *Header* parameter to submit the alternate header. -The results are stored in the $J variable. +The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. -The seventh command displays the object in the $J variable. -The resulting object has MoreData and State properties, as shown in the command output. +The seventh command displays the object in the $J variable. The resulting object has MoreData and State properties, as shown in the command output. ### Example 5: Create a custom object using a CSV file ``` From b1828000f2c0fbcb1de21e9a6fc031f8e14ee533 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:48:23 -0600 Subject: [PATCH 11/45] 3.0 update example 5 --- .../Import-Csv.md | 77 +++++++++++-------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index a610a4811fdc..c5378bf568e6 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -158,44 +158,59 @@ The seventh command displays the object in the $j variable. The resulting object ### Example 5 ``` -The first command uses the Get-Content cmdlet to get the Links.csv file. PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, -about_Core_Commands113220,about_Data_Section… +113207,about_Aliases +113208,about_Arithmetic_Operators +113209,about_Arrays +113210,about_Assignment_Operators +113212,about_Automatic_Variables +113213,about_Break +113214,about_Command_Precedence +113215,about_Command_Syntax +144309,about_Comment_Based_Help +113216,about_CommonParameters +113217,about_Comparison_Operators +113218,about_Continue +113219,about_Core_Commands +113220,about_Data_Section +PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle +PS C:\> $A | Get-Member -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the **Header** parameter to specify **LinkId** and **TopicTitle** as property names for the new custom objects. The command saves the imported objects in the $a variable. -PS C:\> $a = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle -The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $a variable.The output shows that **Import-Csv** returns a collection of custom objects (PSCustomObject). In addition to some default properties, the custom objects have **LinkID** and **TopicTitle** note properties. -PS C:\> $a | Get-Member TypeName: System.Management.Automation.PSCustomObject -Name MemberType Definition ----- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String -TopicTitle=about_Aliases - -This command shows that you can use the custom object like you would any object in Windows PowerShell.The command pipes the custom objects in the $a variable to the **Where-Object** cmdlet, which gets only objects with a **TopicTitle** property that includes "alias".The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. -PS C:\> $a | Where-Object TopicTitle -like "*alias*" -LinkID TopicTitle ------- ---------- -113207 about_Aliases -113432 Alias Provider -113296 Export-Alias -113306 Get-Alias -113339 Import-Alias -113352 New-Alias -113390 Set-Alias + +Name MemberType Definition +---- ---------- ---------- +Equals Method bool Equals(System.Object obj) +GetHashCode Method int GetHashCode() +GetType Method type GetType() +ToString Method string ToString() +LinkID NoteProperty string LinkID=113207 +TopicTitle NoteProperty string TopicTitle=about_Aliases + +PS C:\> $A | Where-Object TopicTitle -Like "*alias*" + +LinkID TopicTitle +------ ---------- +113207 about_Aliases ``` This example shows how to create a custom object in Windows PowerShell by using a CSV file. + +The first command uses the Get-Content cmdlet to get the Links.csv file. + +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $a variable. + +The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $a variable. + +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. + +This command shows that you can use the custom object like you would any object in Windows PowerShell. + +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". + +The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. + ### Example 6 ``` The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." From 8f90f8d2946126da75707f3b6238b2030d29bf82 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:50:22 -0600 Subject: [PATCH 12/45] 4.0 update example 5 --- .../Import-Csv.md | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index d6f8a744e824..51f3263c59fc 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -144,45 +144,59 @@ The seventh command displays the object in the $J variable. The resulting object ### Example 5 ``` -The first command uses the Get-Content cmdlet to get the Links.csv file. PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, -about_Core_Commands113220,about_Data_Section… +113207,about_Aliases +113208,about_Arithmetic_Operators +113209,about_Arrays +113210,about_Assignment_Operators +113212,about_Automatic_Variables +113213,about_Break +113214,about_Command_Precedence +113215,about_Command_Syntax +144309,about_Comment_Based_Help +113216,about_CommonParameters +113217,about_Comparison_Operators +113218,about_Continue +113219,about_Core_Commands +113220,about_Data_Section +PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle +PS C:\> $A | Get-Member -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the **Header** parameter to specify **LinkId** and **TopicTitle** as property names for the new custom objects. The command saves the imported objects in the $a variable. -PS C:\> $a = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle -The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $a variable.The output shows that **Import-Csv** returns a collection of custom objects (PSCustomObject). In addition to some default properties, the custom objects have **LinkID** and **TopicTitle** note properties. -PS C:\> $a | Get-Member TypeName: System.Management.Automation.PSCustomObject -Name MemberType Definition ----- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String -TopicTitle=about_Aliases - -This command shows that you can use the custom object like you would any object in Windows PowerShell.The command pipes the custom objects in the $a variable to the **Where-Object** cmdlet, which gets only objects with a **TopicTitle** property that includes "alias".The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. -PS C:\> $a | Where-Object TopicTitle -like "*alias*" -LinkID TopicTitle ------- ---------- -113207 about_Aliases -113432 Alias Provider -113296 Export-Alias -113306 Get-Alias -113339 Import-Alias -113352 New-Alias -113390 Set-Alias + +Name MemberType Definition +---- ---------- ---------- +Equals Method bool Equals(System.Object obj) +GetHashCode Method int GetHashCode() +GetType Method type GetType() +ToString Method string ToString() +LinkID NoteProperty string LinkID=113207 +TopicTitle NoteProperty string TopicTitle=about_Aliases + +PS C:\> $A | Where-Object TopicTitle -Like "*alias*" + +LinkID TopicTitle +------ ---------- +113207 about_Aliases ``` This example shows how to create a custom object in Windows PowerShell by using a CSV file. +The first command uses the Get-Content cmdlet to get the Links.csv file. + +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $a variable. + +The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $a variable. + +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. + +This command shows that you can use the custom object like you would any object in Windows PowerShell. + +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". + +The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. + ### Example 6 ``` The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." From 996aa311623aa1dcb0178318fcdb7e700d74ecf7 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:50:41 -0600 Subject: [PATCH 13/45] 5.0 update example 5 --- .../5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 20aa104f3456..be7014310d4d 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -195,20 +195,17 @@ This example shows how to create a custom object in Windows PowerShell by using The first command uses the Get-Content cmdlet to get the Links.csv file. -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. -The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. -The command saves the imported objects in the $A variable. +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $A variable. The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $A variable. -The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). -In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. This command shows that you can use the custom object like you would any object in Windows PowerShell. -The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a **TopicTitle** property that includes alias. +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". -The Where-Object command uses the new simplified command format that does not require symbols, script blocks, or curly braces. +The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. ### Example 6: Import a CSV that is missing a value ``` From 4af3d4346cfa7e2dac9a9905a37c37c27e41a4d5 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 21:50:51 -0600 Subject: [PATCH 14/45] 5.1 update example 5 --- .../5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index fa293cb78cf0..9efc27395520 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -207,20 +207,17 @@ This example shows how to create a custom object in Windows PowerShell by using The first command uses the Get-Content cmdlet to get the Links.csv file. -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. -The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. -The command saves the imported objects in the $A variable. +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $A variable. The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $A variable. -The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). -In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. This command shows that you can use the custom object like you would any object in Windows PowerShell. -The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a **TopicTitle** property that includes alias. +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". -The Where-Object command uses the new simplified command format that does not require symbols, script blocks, or curly braces. +The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. ### Example 6: Import a CSV that is missing a value ``` From 26e6383eab57e2d4578ba838ae85d0e6c0cd1e4d Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:01:42 -0600 Subject: [PATCH 15/45] 5.1 update example 6 --- .../5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 9efc27395520..577a4270c17f 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -245,18 +245,15 @@ Europe This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds when the header row in a CSV file includes a null or empty value. -**Import-Csv** substitutes a default name for the header row. -The default name becomes the name of the property of the object that **Import-Csv** returns. +**Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. -The output shows that the header row of the file is missing a value between ProjectName and Completed. +The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed". The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. -The output shows that **Import-Csv** generates a warning and substitutes a default name, H1, for the missing header row value. -H1 is also used for the name of the object property. +The output shows that **Import-Csv** generates a warning and substitutes a default name, "H1", for the missing header row value. "H1" is also used for the name of the object property. -The third command uses the dot method to get the value of the H1 property of the object that **Import-Csv** creates. +The third command uses the dot method to get the value of the "H1" property of the object that **Import-Csv** creates. ## PARAMETERS From 10c034a5c191de6780e3fef961853ba9cfb00741 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:01:52 -0600 Subject: [PATCH 16/45] 5.0 update example 6 --- reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index be7014310d4d..a238bb3f7390 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -236,15 +236,13 @@ This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds **Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. -The output shows that the header row of the file is missing a value between ProjectName and Completed. +The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed". The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. -The output shows that **Import-Csv** generates a warning and substitutes a default name, H1, for the missing header row value. -H1 is also used for the name of the object property. +The output shows that **Import-Csv** generates a warning and substitutes a default name, "H1", for the missing header row value. "H1" is also used for the name of the object property. -The third command uses the dot method to get the value of the H1 property of the object that **Import-Csv** creates. +The third command uses the dot method to get the value of the "H1" property of the object that **Import-Csv** creates. ## PARAMETERS From f70df49914ff9386264b5a5138e76954b812c185 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:02:02 -0600 Subject: [PATCH 17/45] 4.0 update example 6 --- .../Import-Csv.md | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 51f3263c59fc..6b23907d7de1 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -199,27 +199,39 @@ The **Where-Object** command uses the new simplified command format that does no ### Example 6 ``` -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." PS C:\> Get-Content "\\Server2\c$\Test\Projects.csv" -ProjectID, ProjectName,,Completed13, Inventory, Redmond, True440, , FarEast, True469, Marketing, Europe, False - -The second command uses the **Import-Csv** cmdlet to import the Projects.csv file.The output shows that Import-Csv generates a warning and substitutes a default name, H1, for the missing header row value. H1 is also used for the name of the object property. +ProjectID,ProjectName,,Completed +13,Inventory,Redmond,True +440,,FarEast,True +469,Marketing,Europe,False PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. -ProjectID ProjectName H1 Completed ---------- ----------- -- --------- -13 Inventory Redmond True -440 FarEast True -469 Marketing Europe False - -The third command uses the dot method to get the value of the H1 property of the object that **Import-Csv** creates. +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. + +ProjectID ProjectName H1 Completed +--------- ----------- -- --------- +13 Inventory Redmond True +440 FarEast True +469 Marketing Europe False + + PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 -RedmondFarEastEurope +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +Redmond +FarEast +Europe ``` -This example shows how the **Import-Csv** cmdlet in Windows PowerShell 3.0 responds when the header row in a CSV file includes a null or empty value. -**Import-Csv** substitutes a default name for the header row. -The default name becomes the name of the property of the object that **Import-Csv** returns. +This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds when the header row in a CSV file includes a null or empty value. + +**Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. + +The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." + +The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. + +The output shows that **Import-Csv** generates a warning and substitutes a default name, "H1", for the missing header row value. "H1" is also used for the name of the object property. + +The third command uses the dot method to get the value of the "H1" property of the object that **Import-Csv** creates. ## PARAMETERS From 4bc7f191ed7c89395d17f83b014ae4ca44768fa3 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:02:10 -0600 Subject: [PATCH 18/45] 3.0 update example 6 --- .../Import-Csv.md | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index c5378bf568e6..b382e8a06bae 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -213,27 +213,40 @@ The **Where-Object** command uses the new simplified command format that does no ### Example 6 ``` -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." PS C:\> Get-Content "\\Server2\c$\Test\Projects.csv" -ProjectID, ProjectName,,Completed13, Inventory, Redmond, True440, , FarEast, True469, Marketing, Europe, False - -The second command uses the **Import-Csv** cmdlet to import the Projects.csv file.The output shows that Import-Csv generates a warning and substitutes a default name, H1, for the missing header row value. H1 is also used for the name of the object property. +ProjectID,ProjectName,,Completed +13,Inventory,Redmond,True +440,,FarEast,True +469,Marketing,Europe,False PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. -ProjectID ProjectName H1 Completed ---------- ----------- -- --------- -13 Inventory Redmond True -440 FarEast True -469 Marketing Europe False - -The third command uses the dot method to get the value of the H1 property of the object that **Import-Csv** creates. +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. + +ProjectID ProjectName H1 Completed +--------- ----------- -- --------- +13 Inventory Redmond True +440 FarEast True +469 Marketing Europe False + + PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 -RedmondFarEastEurope +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +Redmond +FarEast +Europe ``` -This example shows how the **Import-Csv** cmdlet in Windows PowerShell 3.0 responds when the header row in a CSV file includes a null or empty value. -**Import-Csv** substitutes a default name for the header row. -The default name becomes the name of the property of the object that **Import-Csv** returns. +This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds when the header row in a CSV file includes a null or empty value. + +**Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. + +The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." + +The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. + +The output shows that **Import-Csv** generates a warning and substitutes a default name, "H1", for the missing header row value. "H1" is also used for the name of the object property. + +The third command uses the dot method to get the value of the "H1" property of the object that **Import-Csv** creates. + ## PARAMETERS ### -Delimiter From 7783caac96392402cf3ab3dc51d2772c63928491 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:07:00 -0600 Subject: [PATCH 19/45] 3.0 update format of param Delimiter and Encoding --- .../Import-Csv.md | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index b382e8a06bae..92dc949a2cab 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -251,11 +251,14 @@ The third command uses the dot method to get the value of the "H1" property of t ### -Delimiter Specifies the delimiter that separates the property values in the CSV file. + The default is a comma (,). + Enter a character, such as a colon (:). + To specify a semicolon (;), enclose it in quotation marks. -If you specify a character other than the actual string delimiter in the file, Import-Csv cannot create objects from the CSV strings. +If you specify a character other than the actual string delimiter in the file, **Import-Csv** cannot create objects from the CSV strings. Instead, it returns the strings. ```yaml @@ -272,10 +275,21 @@ Accept wildcard characters: False ### -Encoding Specifies the type of character encoding that was used in the CSV file. -Valid values are Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, and OEM. + +The acceptable values for this parameter are: + +- Unicode +- UTF7 +- UTF8 +- ASCII +- UTF32 +- BigEndianUnicode +- Default +- OEM + The default is ASCII. -This parameter is introduced in Windows PowerShell 3.0. +This parameter was introduced in Windows PowerShell 3.0. ```yaml Type: String From 05003fd45347b06b48bac053a88de8a9a39e4028 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:07:08 -0600 Subject: [PATCH 20/45] 4.0 update format of param Delimiter and Encoding --- .../Import-Csv.md | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 6b23907d7de1..bf25fd76eaec 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -237,11 +237,14 @@ The third command uses the dot method to get the value of the "H1" property of t ### -Delimiter Specifies the delimiter that separates the property values in the CSV file. + The default is a comma (,). + Enter a character, such as a colon (:). + To specify a semicolon (;), enclose it in quotation marks. -If you specify a character other than the actual string delimiter in the file, Import-Csv cannot create objects from the CSV strings. +If you specify a character other than the actual string delimiter in the file, **Import-Csv** cannot create objects from the CSV strings. Instead, it returns the strings. ```yaml @@ -258,10 +261,21 @@ Accept wildcard characters: False ### -Encoding Specifies the type of character encoding that was used in the CSV file. -Valid values are Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, and OEM. + +The acceptable values for this parameter are: + +- Unicode +- UTF7 +- UTF8 +- ASCII +- UTF32 +- BigEndianUnicode +- Default +- OEM + The default is ASCII. -This parameter is introduced in Windows PowerShell 3.0. +This parameter was introduced in Windows PowerShell 3.0. ```yaml Type: String From 01edacf1aa247b43bd258a0e233ac5eb00067654 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:07:50 -0600 Subject: [PATCH 21/45] 5.0 update format of param Encoding --- reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 1 + 1 file changed, 1 insertion(+) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index a238bb3f7390..4743b0f8a2e4 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -272,6 +272,7 @@ Accept wildcard characters: False ### -Encoding Specifies the type of character encoding that was used in the CSV file. + The acceptable values for this parameter are: - Unicode From 5315a8dc738eb970e4dc50247c59154ada72416d Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:08:04 -0600 Subject: [PATCH 22/45] 5.1 update format of param Encoding --- reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 1 + 1 file changed, 1 insertion(+) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 577a4270c17f..22e0d4c77f9d 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -283,6 +283,7 @@ Accept wildcard characters: False ### -Encoding Specifies the type of character encoding that was used in the CSV file. + The acceptable values for this parameter are: - Unicode From 34d09e345c73651bfb135517481739391f6ad852 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:09:59 -0600 Subject: [PATCH 23/45] 5.0 update param header --- reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 4743b0f8a2e4..64ac3e8086c7 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -302,8 +302,7 @@ Accept wildcard characters: False ``` ### -Header -Specifies an alternate column header row for the imported file. -The column header determines the names of the properties of the object that **Import-Csv** creates. +Specifies an alternate column header row for the imported file. The column header determines the names of the properties of the object that **Import-Csv** creates. Enter a comma-separated list of the column headers. @@ -315,8 +314,7 @@ If you enter fewer column headers than there are columns, the remaining columns If you enter more headers than there are columns, the extra headers are ignored. -When using the *Header* parameter, delete the original header row from the CSV file. -Otherwise, **Import-Csv** creates an extra object from the items in the header row. +When using the *Header* parameter, delete the original header row from the CSV file. Otherwise, **Import-Csv** creates an extra object from the items in the header row. ```yaml Type: String[] From 59c62085397a3ebc222b3a3507fa255063381d19 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:10:24 -0600 Subject: [PATCH 24/45] 4.0 update param header info --- .../4.0/Microsoft.PowerShell.Utility/Import-Csv.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index bf25fd76eaec..17c063890418 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -290,17 +290,19 @@ Accept wildcard characters: False ``` ### -Header -Specifies an alternate column header row for the imported file. -The column header determines the names of the properties of the object that Import-Csv creates. +Specifies an alternate column header row for the imported file. The column header determines the names of the properties of the object that **Import-Csv** creates. Enter a comma-separated list of the column headers. + Enclose each item in quotation marks (single or double). + Do not enclose the header string in quotation marks. + If you enter fewer column headers than there are columns, the remaining columns will have no header. + If you enter more headers than there are columns, the extra headers are ignored. -When using the *Header* parameter, delete the original header row from the CSV file. -Otherwise, Import-Csv creates an extra object from the items in the header row. +When using the *Header* parameter, delete the original header row from the CSV file. Otherwise, **Import-Csv** creates an extra object from the items in the header row. ```yaml Type: String[] From eef8f8578e6915ce670ce7ed0b54e6b0b7836fe9 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:10:29 -0600 Subject: [PATCH 25/45] 3.0 update param header info --- .../3.0/Microsoft.PowerShell.Utility/Import-Csv.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 92dc949a2cab..734c888641af 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -304,17 +304,19 @@ Accept wildcard characters: False ``` ### -Header -Specifies an alternate column header row for the imported file. -The column header determines the names of the properties of the object that Import-Csv creates. +Specifies an alternate column header row for the imported file. The column header determines the names of the properties of the object that **Import-Csv** creates. Enter a comma-separated list of the column headers. + Enclose each item in quotation marks (single or double). + Do not enclose the header string in quotation marks. + If you enter fewer column headers than there are columns, the remaining columns will have no header. + If you enter more headers than there are columns, the extra headers are ignored. -When using the *Header* parameter, delete the original header row from the CSV file. -Otherwise, Import-Csv creates an extra object from the items in the header row. +When using the *Header* parameter, delete the original header row from the CSV file. Otherwise, **Import-Csv** creates an extra object from the items in the header row. ```yaml Type: String[] From d4b6fc9c44b8dbab561b32d4bfda9619be7589ef Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:19:39 -0600 Subject: [PATCH 26/45] 5.1 update remaining parameter format --- reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 22e0d4c77f9d..345193994c8e 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -341,8 +341,10 @@ Accept wildcard characters: False ### -LiteralPath Specifies the path to the CSV file to import. -Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. -No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. + +Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. + +If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. ```yaml @@ -359,6 +361,7 @@ Accept wildcard characters: False ### -Path Specifies the path to the CSV file to import. + You can also pipe a path to **Import-Csv**. ```yaml @@ -375,9 +378,11 @@ Accept wildcard characters: False ### -UseCulture Indicates that this cmdlet uses the list separator for the current culture as the item delimiter. + The default is based on the culture settings of the Operating System (e.g. en-US culture will return a comma (,) by default). To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. + If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-Csv cannot create objects from the CSV strings. Instead, it returns the strings. From df1c1bafb5a577b4883aff68dc97e950eb840587 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:19:50 -0600 Subject: [PATCH 27/45] 5.0 update remaining parameter format --- .../5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 64ac3e8086c7..4f0d802bb781 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -330,11 +330,10 @@ Accept wildcard characters: False ### -LiteralPath Specifies the path to the CSV file to import. -Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. -No characters are interpreted as wildcards. -If the path includes escape characters, enclose it in single quotation marks. -Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. +Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. + +If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. ```yaml Type: String[] @@ -350,6 +349,7 @@ Accept wildcard characters: False ### -Path Specifies the path to the CSV file to import. + You can also pipe a path to **Import-Csv**. ```yaml @@ -366,9 +366,11 @@ Accept wildcard characters: False ### -UseCulture Indicates that this cmdlet uses the list separator for the current culture as the item delimiter. + The default is based on the culture settings of the Operating System (e.g. en-US culture will return a comma (,) by default). To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. + If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-Csv cannot create objects from the CSV strings. Instead, it returns the strings. From 36a433096533fd3679ee5217264ad6ac1b005c72 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:19:55 -0600 Subject: [PATCH 28/45] 4.0 update remaining parameter format --- .../Import-Csv.md | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 17c063890418..bb28e45c3041 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -316,9 +316,29 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -LiteralPath +Specifies the path to the CSV file to import. + +Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. + +If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: PSPath + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -Path Specifies the path to the CSV file to import. -You can also pipe a path to Import-Csv. + +You can also pipe a path to **Import-Csv**. ```yaml Type: String[] @@ -334,9 +354,11 @@ Accept wildcard characters: False ### -UseCulture Use the list separator for the current culture as the item delimiter. -The default is a comma (,). -To find the list separator for a culture, use the following command: (Get-Culture).TextInfo.ListSeparator. +The default is based on the culture settings of the Operating System (e.g. en-US culture will ret + +To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. + If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-CSV cannot create objects from the CSV strings. Instead, it returns the strings. @@ -352,25 +374,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -LiteralPath -Specifies the path to the CSV file to import. -Unlike **Path**, the value of the **LiteralPath** parameter is used exactly as it is typed. -No characters are interpreted as wildcards. -If the path includes escape characters, enclose it in single quotation marks. -Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: PSPath - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). From 1d6c9e61096ed2f7487dfca27e335c7ddb78e0a6 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:20:02 -0600 Subject: [PATCH 29/45] 3.0 update remaining parameter format --- .../Import-Csv.md | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 734c888641af..ca107dda4477 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -330,9 +330,29 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -LiteralPath +Specifies the path to the CSV file to import. + +Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. + +If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: PSPath + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -Path Specifies the path to the CSV file to import. -You can also pipe a path to Import-Csv. + +You can also pipe a path to **Import-Csv**. ```yaml Type: String[] @@ -366,25 +386,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -LiteralPath -Specifies the path to the CSV file to import. -Unlike **Path**, the value of the **LiteralPath** parameter is used exactly as it is typed. -No characters are interpreted as wildcards. -If the path includes escape characters, enclose it in single quotation marks. -Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: PSPath - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS From eabb5eae1864508ad005ca6e426ce01eee0a97e0 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:20:17 -0600 Subject: [PATCH 30/45] 3.0 update remaining parameter format --- reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index ca107dda4477..63fa0cab5cca 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -368,9 +368,11 @@ Accept wildcard characters: False ### -UseCulture Use the list separator for the current culture as the item delimiter. -The default is a comma (,). -To find the list separator for a culture, use the following command: (Get-Culture).TextInfo.ListSeparator. +The default is based on the culture settings of the Operating System (e.g. en-US culture will ret + +To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. + If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-CSV cannot create objects from the CSV strings. Instead, it returns the strings. From c5d09531b3182d87a346217a00c719c697b232d4 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:25:47 -0600 Subject: [PATCH 31/45] 5.1 update notes format and add related link --- reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 345193994c8e..380b237483d9 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -413,9 +413,9 @@ This cmdlet returns the objects described by the content in the CSV file. ## NOTES * Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the Windows PowerShell type formatting entries that format the non-CSV versions of the object type. -* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the **Count** property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. +* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the *Count* property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. * The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the *Header* parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. -* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses H followed by a number for the missing column header and property name. +* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. * In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-Csv does not export the methods of the object. ## RELATED LINKS From f36af18949574fd6228237a7fdd729283357c625 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:25:54 -0600 Subject: [PATCH 32/45] 5.0 update notes format and add related link --- reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 4f0d802bb781..07a6b86dfd23 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -401,9 +401,9 @@ This cmdlet returns the objects described by the content in the CSV file. ## NOTES * Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the Windows PowerShell type formatting entries that format the non-CSV versions of the object type. -* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the **Count** property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. +* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the *Count* property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. * The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the *Header* parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. -* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses H followed by a number for the missing column header and property name. +* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. * In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-Csv does not export the methods of the object. ## RELATED LINKS @@ -414,3 +414,4 @@ This cmdlet returns the objects described by the content in the CSV file. [Export-Csv](Export-Csv.md) +[Get-Culture](Get-Culture.md) \ No newline at end of file From 7e9dabc4478b920202db167d1ec9642b112b0367 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:26:01 -0600 Subject: [PATCH 33/45] 4.0 update notes format and add related link --- .../Import-Csv.md | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index bb28e45c3041..f201e529d76a 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -380,26 +380,19 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS ### System.String -You can pipe a string that contains a path to Import-Csv. +You can pipe a string that contains a path to **Import-Csv**. ## OUTPUTS ### Object. -Import-Csv returns the objects described by the content in the CSV file. +This cmdlet returns the objects described by the content in the CSV file. ## NOTES * Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the Windows PowerShell type formatting entries that format the non-CSV versions of the object type. -* The result of an Import-Csv command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the Count property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. - - The column header row determines the number of columns and the column names. -The column names are also the names of the properties of the objects. -The first row is interpreted to be the column headers, unless you use the Header parameter to specify column headers. -If any row has more values than the header row, the additional values are ignored. - - If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. - - In the CSV file, each object is represented by a comma-separated list of the property values of the object. -The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. +* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the Count property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. +* The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the Header parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. +* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. +* In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-CSV does not export the methods of the object. ## RELATED LINKS @@ -410,3 +403,4 @@ Export-CSV does not export the methods of the object. [Export-Csv](Export-Csv.md) +[Get-Culture](Get-Culture.md) \ No newline at end of file From ecf861162258df9eb8535c7d2baae24e79ef063a Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 22:26:04 -0600 Subject: [PATCH 34/45] 3.0 update notes format and add related link --- .../Import-Csv.md | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 63fa0cab5cca..525331b123b7 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -390,28 +390,25 @@ Accept wildcard characters: False ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### System.String You can pipe a string that contains a path to Import-Csv. + ## OUTPUTS ### Object. -Import-Csv returns the objects described by the content in the CSV file. +This cmdlet returns the objects described by the content in the CSV file. + ## NOTES * Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the Windows PowerShell type formatting entries that format the non-CSV versions of the object type. -* The result of an Import-Csv command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the Count property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. - - The column header row determines the number of columns and the column names. -The column names are also the names of the properties of the objects. -The first row is interpreted to be the column headers, unless you use the Header parameter to specify column headers. -If any row has more values than the header row, the additional values are ignored. - - If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. - - In the CSV file, each object is represented by a comma-separated list of the property values of the object. -The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. +* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the Count property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. +* The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the Header parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. +* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. +* In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-CSV does not export the methods of the object. + ## RELATED LINKS [ConvertFrom-Csv](ConvertFrom-Csv.md) @@ -420,3 +417,4 @@ Export-CSV does not export the methods of the object. [Export-Csv](Export-Csv.md) +[Get-Culture](Get-Culture.md) \ No newline at end of file From 0df842a042ebff06ea74f505e143ca8c201dc722 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 23:12:19 -0600 Subject: [PATCH 35/45] update to example 1 across 3.0 to 5.1 --- .../Import-Csv.md | 8 ++--- .../Import-Csv.md | 32 ++++++++++++++----- .../Import-Csv.md | 13 +++----- .../Import-Csv.md | 13 +++----- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 525331b123b7..aa7f43eb38a0 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -43,8 +43,8 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file ### Example 1 ``` -PS C:\> Get-Process | Export-Csv processes.csv -PS C:\> $P = Import-Csv processes.csv +PS C:\> Get-Process | Export-Csv Processes.csv +PS C:\> $P = Import-Csv Processes.csv PS C:\> $P | Get-Member TypeName: CSV:System.Diagnostics.Process Name MemberType Definition @@ -73,9 +73,9 @@ This example shows how to export and then import a CSV file of objects. The first command uses the Get-Process cmdlet to get the process on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-CSV cmdlet, which exports the process objects to the Processes.csv file in the current directory. -The second command uses the **Import-Csv** cmdlet to import the processes in the **Import-Csv** file. Then it saves the resulting process objects in the $P variable. +The second command uses the **Import-Csv** cmdlet to import the processes in the Processes.csv file. Then it saves the resulting process objects in the $P variable. -The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlets. The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that **Get-Process** returns. +The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlets. The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that Get-Process returns. Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted. diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index f201e529d76a..c9c0f8ec7ce8 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -44,14 +44,9 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file ### Example 1 ``` -This example shows how to export and then import a CSV file of objects.The first command uses the Get-Process cmdlet to get the process on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-CSV cmdlet, which exports the process objects to the Processes.csv file in the current directory. -PS C:\> get-process | export-csv processes.csv - -The second command uses the Import-Csv cmdlet to import the processes in the Import-Csv file. Then it saves the resulting process objects in the $P variable. +PS C:\> Get-Process | Export-Csv processes.csv PS C:\> $P = Import-Csv processes.csv - -The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlets. The result shows that they are CSV:System.Diagnostic.Process objects, not the System.Diagnostic.Process objects that Get-Process returns.Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted.To display the objects, use the formatting cmdlets, such as Format-Table and Format-List, or pipe the objects to Out-GridView. -PS C:\> $P | get-member +PS C:\> $P | Get-Member TypeName: CSV:System.Diagnostics.Process Name MemberType Definition ---- ---------- ---------- @@ -62,11 +57,32 @@ ToString Method System.String ToString() BasePriority NoteProperty System.String BasePriority=8 Company NoteProperty System.String Company=Microsoft Corporation ... -PS C:\> $P | out-gridview +PS C:\> $P | Format-Table + +Name SI Handles VM WS PM NPM Path +---- -- ------- -- -- -- --- ---- +ApplicationFrameHost 4 407 2199293489152 15884288 15151104 23792 C:\WINDOWS\system32\ApplicationFrameHost.exe +... +wininit 0 157 2199112204288 4591616 1630208 10376 +winlogon 4 233 2199125549056 7659520 2826240 10992 C:\WINDOWS\System32\WinLogon.exe +WinStore.App 4 846 873435136 33652736 26607616 55432 C:\Program Files\WindowsApps\Microsoft.WindowsStore_11712.1001.13.0_x64__8weky... +WmiPrvSE 0 201 2199100219392 8830976 3297280 10632 C:\WINDOWS\system32\wbem\wmiprvse.exe +WmiPrvSE 0 407 2199157727232 18509824 12922880 16624 C:\WINDOWS\system32\wbem\wmiprvse.exe +WUDFHost 0 834 2199310204928 51945472 87441408 24984 C:\Windows\System32\WUDFHost.exe ``` This example shows how to export and then import a CSV file of objects. +The first command uses the Get-Process cmdlet to get the process on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-CSV cmdlet, which exports the process objects to the Processes.csv file in the current directory. + +The second command uses the **Import-Csv** cmdlet to import the processes in the Processes.csv file. Then it saves the resulting process objects in the $P variable. + +The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlets. The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that Get-Process returns. + +Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted. + +To display the objects, use the formatting cmdlets, such as Format-Table and Format-List, or pipe the objects to Out-GridView. + ### Example 2 ``` PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 07a6b86dfd23..a97b9fc26e59 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -44,8 +44,8 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file ### Example 1: Import process objects ``` -PS C:\> Get-Process | Export-Csv processes.csv -PS C:\> $P = Import-Csv processes.csv +PS C:\> Get-Process | Export-Csv Processes.csv +PS C:\> $P = Import-Csv Processes.csv PS C:\> $P | Get-Member PS C:\> $P | Format-Table TypeName: CSV:System.Diagnostics.Process @@ -63,14 +63,11 @@ Company NoteProperty System.String Company=Microsoft Corporat This example shows how to export and then import a CSV file of process objects. -The first command uses the Get-Process cmdlet to get the processes on the local computer. -It uses a pipeline operator (|) to send the process objects to the Export-Csv cmdlet, which exports the process objects to the Processes.csv file in the current directory. +The first command uses the Get-Process cmdlet to get the processes on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-Csv cmdlet, which exports the process objects to the Processes.csv file in the current directory. -The second command uses the **Import-Csv** cmdlet to import the processes in the **Import-Csv** file. -Then it saves the resulting process objects in the $P variable. +The second command uses the **Import-Csv** cmdlet to import the processes in the Processes.csv file. Then it saves the resulting process objects in the $P variable. -The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlet. -The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that **Get-Process** returns. +The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlet. The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that Get-Process returns. Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted. diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 380b237483d9..973aa4520977 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -44,8 +44,8 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file ### Example 1: Import process objects ``` -PS C:\> Get-Process | Export-Csv processes.csv -PS C:\> $P = Import-Csv processes.csv +PS C:\> Get-Process | Export-Csv Processes.csv +PS C:\> $P = Import-Csv Processes.csv PS C:\> $P | Get-Member @@ -76,14 +76,11 @@ WUDFHost 0 834 2199310204928 51945472 87441408 24984 C:\Wi This example shows how to export and then import a CSV file of process objects. -The first command uses the Get-Process cmdlet to get the processes on the local computer. -It uses a pipeline operator (|) to send the process objects to the Export-Csv cmdlet, which exports the process objects to the Processes.csv file in the current directory. +The first command uses the Get-Process cmdlet to get the processes on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-Csv cmdlet, which exports the process objects to the Processes.csv file in the current directory. -The second command uses the **Import-Csv** cmdlet to import the processes in the **Import-Csv** file. -Then it saves the resulting process objects in the $P variable. +The second command uses the **Import-Csv** cmdlet to import the processes in the Processes.csv file. Then it saves the resulting process objects in the $P variable. -The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlet. -The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that **Get-Process** returns. +The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlet. The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that Get-Process returns. Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted. From 26cb1acd79dc83a3ba610ca3bcf078112b8dd718 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 23:12:42 -0600 Subject: [PATCH 36/45] 6.0 Updates to description and example 1 --- .../Import-Csv.md | 81 ++++++++++--------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md index 69652609c673..6035b206e9fd 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md @@ -30,49 +30,54 @@ Import-Csv [[-Path] ] [-LiteralPath ] [-UseCulture] [-Header ``` ## DESCRIPTION -The **Import-Csv** cmdlet creates table-like custom objects from the items in CSV files. -Each column in the CSV file becomes a property of the custom object and the items in rows become the property values. -**Import-Csv** works on any CSV file, including files that are generated by the Export-Csv cmdlet. +The **Import-Csv** cmdlet creates table-like custom objects from the items in CSV files. Each column in the CSV file becomes a property of the custom object and the items in rows become the property values. **Import-Csv** works on any CSV file, including files that are generated by the Export-Csv cmdlet. You can use the parameters of the **Import-Csv** cmdlet to specify the column header row and the item delimiter, or direct **Import-Csv** to use the list separator for the current culture as the item delimiter. -You can also use the ConvertTo-Csv and ConvertFrom-Csv cmdlets to convert objects to CSV strings (and back). -These cmdlets are the same as the **Export-CSV** and **Import-Csv** cmdlets, except that they do not deal with files. +You can also use the ConvertTo-Csv and ConvertFrom-Csv cmdlets to convert objects to CSV strings (and back). These cmdlets are the same as the **Export-CSV** and **Import-Csv** cmdlets, except that they do not deal with files. -Beginning in Windows PowerShell 3.0, if a header row entry in a CSV file contains an empty or null value, Windows PowerShell inserts a default header row name and displays a warning message. -In previous versions of Windows PowerShell, if a header row entry in a CSV file contains an empty or null value, the **Import-Csv** command fails. +If a header row entry in a CSV file contains an empty or null value, PowerShell inserts a default header row name and displays a warning message. ## EXAMPLES ### Example 1: Import process objects ``` -PS C:\> Get-Process | Export-Csv processes.csv -PS C:\> $P = Import-Csv processes.csv +PS C:\> Get-Process | Export-Csv Processes.csv +PS C:\> $P = Import-Csv Processes.csv PS C:\> $P | Get-Member -PS C:\> $P | Format-Table -TypeName: CSV:System.Diagnostics.Process + + + TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- -Equals Method System.Boolean Equals(Object obj) -GetHashCode Method System.Int32 GetHashCode() -GetType Method System.Type GetType() -ToString Method System.String ToString() -BasePriority NoteProperty System.String BasePriority=8 -Company NoteProperty System.String Company=Microsoft Corporation +Equals Method bool Equals(System.Object obj) +GetHashCode Method int GetHashCode() +GetType Method type GetType() +ToString Method string ToString() +BasePriority NoteProperty string BasePriority=8 +Company NoteProperty string Company=Microsoft Corporation +... +PS C:\> $P | Format-Table +Name SI Handles VM WS PM NPM Path +---- -- ------- -- -- -- --- ---- +ApplicationFrameHost 4 407 2199293489152 15884288 15151104 23792 C:\WINDOWS\system32\ApplicationFrameHost.exe ... +wininit 0 157 2199112204288 4591616 1630208 10376 +winlogon 4 233 2199125549056 7659520 2826240 10992 C:\WINDOWS\System32\WinLogon.exe +WinStore.App 4 846 873435136 33652736 26607616 55432 C:\Program Files\WindowsApps\Microsoft.WindowsStore_11712.1001.13.0_x64__8weky... +WmiPrvSE 0 201 2199100219392 8830976 3297280 10632 C:\WINDOWS\system32\wbem\wmiprvse.exe +WmiPrvSE 0 407 2199157727232 18509824 12922880 16624 C:\WINDOWS\system32\wbem\wmiprvse.exe +WUDFHost 0 834 2199310204928 51945472 87441408 24984 C:\Windows\System32\WUDFHost.exe ``` This example shows how to export and then import a CSV file of process objects. -The first command uses the Get-Process cmdlet to get the processes on the local computer. -It uses a pipeline operator (|) to send the process objects to the Export-Csv cmdlet, which exports the process objects to the Processes.csv file in the current directory. +The first command uses the Get-Process cmdlet to get the processes on the local computer. It uses a pipeline operator (|) to send the process objects to the Export-Csv cmdlet, which exports the process objects to the Processes.csv file in the current directory. -The second command uses the **Import-Csv** cmdlet to import the processes in the **Import-Csv** file. -Then it saves the resulting process objects in the $P variable. +The second command uses the **Import-Csv** cmdlet to import the processes in the Processes.csv file. Then it saves the resulting process objects in the $P variable. -The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlet. -The result shows that they are **CSV:System.Diagnostic.Process** objects, not the **System.Diagnostic.Process** objects that **Get-Process** returns. +The third command uses a pipeline operator to pipe the imported objects to the Get-Member cmdlet. The result shows that they are **System.Management.Automation.PSCustomObject** objects, not the **System.Diagnostic.Process** objects that Get-Process returns. Also, because there is no entry type in the formatting files for the CSV version of the process objects, these objects are not formatted in the same way that standard process objects are formatted. @@ -158,21 +163,21 @@ The resulting object has MoreData and State properties, as shown in the command ### Example 5: Create a custom object using a CSV file ``` PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, +113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, +about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, +about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, about_Core_Commands113220,about_Data_Section… PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle PS C:\> $A | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String +Equals Method bool +Equals(System.Object obj) +GetHashCode Method int +GetHashCode()GetType Method type +GetType()ToString Method string +ToString()LinkID NoteProperty System.String +LinkID=113207TopicTitle NoteProperty System.String TopicTitle=about_Aliases PS C:\> $A | Where-Object TopicTitle -Like "*alias*" LinkID TopicTitle ------ ---------- @@ -245,7 +250,7 @@ Instead, it returns the strings. ```yaml Type: Char Parameter Sets: Delimiter -Aliases: +Aliases: Required: False Position: 2 @@ -274,7 +279,7 @@ This parameter was introduced in Windows PowerShell 3.0. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Accepted values: Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, OEM Required: False @@ -300,7 +305,7 @@ Otherwise, **Import-Csv** creates an extra object from the items in the header r ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -343,7 +348,7 @@ You can also pipe a path to **Import-Csv**. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: 1 @@ -363,7 +368,7 @@ Instead, it returns the strings. ```yaml Type: SwitchParameter Parameter Sets: UseCulture -Aliases: +Aliases: Required: True Position: Named From 774b971fbc519d8cb2c8d08494ba28a343250c90 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 23:14:17 -0600 Subject: [PATCH 37/45] 4.0 update to example 1 --- reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index c9c0f8ec7ce8..9c8aaa8fe5e2 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -44,8 +44,8 @@ In previous versions of Windows PowerShell, if a header row entry in a CSV file ### Example 1 ``` -PS C:\> Get-Process | Export-Csv processes.csv -PS C:\> $P = Import-Csv processes.csv +PS C:\> Get-Process | Export-Csv Processes.csv +PS C:\> $P = Import-Csv Processes.csv PS C:\> $P | Get-Member TypeName: CSV:System.Diagnostics.Process Name MemberType Definition From 2c6ecf473139ef279409751b10370ba9ffaa7101 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 23:18:46 -0600 Subject: [PATCH 38/45] 3.0 - 5.1 update case of file name --- reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md | 9 +++++---- reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md | 9 +++++---- reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 9 +++++---- reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 9 +++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index aa7f43eb38a0..01560127e040 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -83,19 +83,20 @@ To display the objects, use the formatting cmdlets, such as Format-Table and For ### Example 2 ``` -PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : -PS C:\> $P = Import-Csv processes.csv -Delimiter : +PS C:\> Get-Process | Export-Csv Processes.csv -Delimiter : +PS C:\> $P = Import-Csv Processes.csv -Delimiter : ``` This example shows how to use the *Delimiter* parameter of the **Import-Csv** cmdlet. + In this example, the processes are exported to a file that uses a colon (:) as a delimiter. When importing, the **Import-Csv** file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. ### Example 3 ``` -PS C:\> Get-Process | Export-Csv processes.csv -UseCulture -PS C:\> $P = Import-Csv processes.csv -UseCulture +PS C:\> Get-Process | Export-Csv Processes.csv -UseCulture +PS C:\> $P = Import-Csv Processes.csv -UseCulture PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 9c8aaa8fe5e2..7d909f3fcf7a 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -85,19 +85,20 @@ To display the objects, use the formatting cmdlets, such as Format-Table and For ### Example 2 ``` -PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : -PS C:\> $P = Import-Csv processes.csv -Delimiter : +PS C:\> Get-Process | Export-Csv Processes.csv -Delimiter : +PS C:\> $P = Import-Csv Processes.csv -Delimiter : ``` This example shows how to use the *Delimiter* parameter of the **Import-Csv** cmdlet. + In this example, the processes are exported to a file that uses a colon (:) as a delimiter. When importing, the **Import-Csv** file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. ### Example 3 ``` -PS C:\> Get-Process | Export-Csv processes.csv -UseCulture -PS C:\> $P = Import-Csv processes.csv -UseCulture +PS C:\> Get-Process | Export-Csv Processes.csv -UseCulture +PS C:\> $P = Import-Csv Processes.csv -UseCulture PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index a97b9fc26e59..e6e7176e71dd 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -75,19 +75,20 @@ To display the objects, use the formatting cmdlets, such as Format-Table and For ### Example 2: Specify the delimiter ``` -PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : -PS C:\> $P = Import-Csv processes.csv -Delimiter : +PS C:\> Get-Process | Export-Csv Processes.csv -Delimiter : +PS C:\> $P = Import-Csv Processes.csv -Delimiter : ``` This example shows how to use the *Delimiter* parameter of the **Import-Csv** cmdlet. + In this example, the processes are exported to a file that uses a colon (:) as a delimiter. When importing, the **Import-Csv** file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. ### Example 3: Specify the current culture for the delimiter ``` -PS C:\> Get-Process | Export-Csv processes.csv -UseCulture -PS C:\> $P = Import-Csv processes.csv -UseCulture +PS C:\> Get-Process | Export-Csv Processes.csv -UseCulture +PS C:\> $P = Import-Csv Processes.csv -UseCulture PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 973aa4520977..718ad13494c4 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -88,19 +88,20 @@ To display the objects, use the formatting cmdlets, such as Format-Table and For ### Example 2: Specify the delimiter ``` -PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : -PS C:\> $P = Import-Csv processes.csv -Delimiter : +PS C:\> Get-Process | Export-Csv Processes.csv -Delimiter : +PS C:\> $P = Import-Csv Processes.csv -Delimiter : ``` This example shows how to use the *Delimiter* parameter of the **Import-Csv** cmdlet. + In this example, the processes are exported to a file that uses a colon (:) as a delimiter. When importing, the **Import-Csv** file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. ### Example 3: Specify the current culture for the delimiter ``` -PS C:\> Get-Process | Export-Csv processes.csv -UseCulture -PS C:\> $P = Import-Csv processes.csv -UseCulture +PS C:\> Get-Process | Export-Csv Processes.csv -UseCulture +PS C:\> $P = Import-Csv Processes.csv -UseCulture PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` From 46701ce4574e177285d4fb17e0b08009bd27ea7e Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 23:19:03 -0600 Subject: [PATCH 39/45] 6.0 update example 2 and 3 --- .../Microsoft.PowerShell.Utility/Import-Csv.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md index 6035b206e9fd..4b7649d314f8 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md @@ -85,30 +85,30 @@ To display the objects, use the formatting cmdlets, such as Format-Table and For ### Example 2: Specify the delimiter ``` -PS C:\> Get-Process | Export-Csv processes.csv -Delimiter : -PS C:\> $P = Import-Csv processes.csv -Delimiter : +PS C:\> Get-Process | Export-Csv Processes.csv -Delimiter : +PS C:\> $P = Import-Csv Processes.csv -Delimiter : ``` This example shows how to use the *Delimiter* parameter of the **Import-Csv** cmdlet. + In this example, the processes are exported to a file that uses a colon (:) as a delimiter. When importing, the **Import-Csv** file uses the *Delimiter* parameter to indicate the delimiter that is used in the file. ### Example 3: Specify the current culture for the delimiter ``` -PS C:\> $P = Import-Csv processes.csv -UseCulture -PS C:\> (Get-Culture).textinfo.listseparator +PS C:\> Get-Process | Export-Csv Processes.csv -UseCulture +PS C:\> $P = Import-Csv Processes.csv -UseCulture +PS C:\> (Get-Culture).TextInfo.ListSeparator , ``` This example shows how to use the *UseCulture* parameter of the **Import-Csv** cmdlet. -The first command imports the objects in the Processes.csv file into the $P variable. -It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. +In this example the processes are exported to a file that uses the culture as a delimiter. The next command imports the objects in the Processes.csv file into the $P variable. It uses the *UseCulture* parameter to direct **Import-Csv** to use the list separator defined for the current culture. + +The second command displays the list separator for the current culture. It uses the Get-Culture cmdlet to get the current culture. It uses the dot (.) method to get the TextInfo property of the current culture and the ListSeparator property of the object in TextInfo. -The second command displays the list separator for the current culture. -It uses the Get-Culture cmdlet to get the current culture. -It uses the dot (.) method to get the TextInfo property of the current culture and the ListSeparator property of the object in TextInfo. In this example, the command returns a comma. ### Example 4: Change property names in an imported object From 75955cd3698a4107ce6afedbb1c575cb42207ed1 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 23:37:33 -0600 Subject: [PATCH 40/45] 3.0 - 5.1 update case of file name --- .../3.0/Microsoft.PowerShell.Utility/Import-Csv.md | 10 +++++----- .../4.0/Microsoft.PowerShell.Utility/Import-Csv.md | 10 +++++----- .../5.0/Microsoft.PowerShell.Utility/Import-Csv.md | 10 +++++----- .../5.1/Microsoft.PowerShell.Utility/Import-Csv.md | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 01560127e040..3d5a9cef1885 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -114,15 +114,15 @@ In this example, the command returns a comma. ### Example 4 ``` -PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv jobs.csv +PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" # Delete header from file -PS C:\> $A = (Get-Content jobs.csv) -PS C:\> $A = $A[0], $A[2..($A.count - 1)] -PS C:\> $A > jobs.csv -PS C:\> $J = Import-Csv jobs.csv -Header $Header +PS C:\> $A = Get-Content Jobs.csv +PS C:\> $A = $A[0], $A[2..($A.Count - 1)] +PS C:\> $A > Jobs.csv +PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 7d909f3fcf7a..d07b3b23afbd 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -116,15 +116,15 @@ In this example, the command returns a comma. ### Example 4 ``` -PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv jobs.csv +PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" # Delete header from file -PS C:\> $A = (Get-Content jobs.csv) -PS C:\> $A = $A[0], $A[2..($A.count - 1)] -PS C:\> $A > jobs.csv -PS C:\> $J = Import-Csv jobs.csv -Header $Header +PS C:\> $A = Get-Content Jobs.csv +PS C:\> $A = $A[0], $A[2..($A.Count - 1)] +PS C:\> $A > Jobs.csv +PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index e6e7176e71dd..1a66a894d820 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -106,15 +106,15 @@ In this example, the command returns a comma. ### Example 4: Change property names in an imported object ``` -PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv jobs.csv +PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" # Delete header from file -PS C:\> $A = (Get-Content jobs.csv) -PS C:\> $A = $A[0], $A[2..($A.count - 1)] -PS C:\> $A > jobs.csv -PS C:\> $J = Import-Csv jobs.csv -Header $Header +PS C:\> $A = Get-Content Jobs.csv +PS C:\> $A = $A[0], $A[2..($A.Count - 1)] +PS C:\> $A > Jobs.csv +PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 718ad13494c4..4cc398b56f1f 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -118,15 +118,15 @@ In this example, the command returns a comma. ### Example 4: Change property names in an imported object ``` -PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv jobs.csv +PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" # Delete header from file -PS C:\> $A = (Get-Content jobs.csv) -PS C:\> $A = $A[0], $A[2..($A.count - 1)] -PS C:\> $A > jobs.csv -PS C:\> $J = Import-Csv jobs.csv -Header $Header +PS C:\> $A = Get-Content Jobs.csv +PS C:\> $A = $A[0], $A[2..($A.Count - 1)] +PS C:\> $A > Jobs.csv +PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J From f9b2e5746ef6571f151171cbd7086ace2b25b4f3 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Fri, 26 Jan 2018 23:38:44 -0600 Subject: [PATCH 41/45] 6.0 working on updating example 4 This example does not give same results I have on 6.0.1. Think other examples are going to be bad as well, have to go back and test those. --- .../6/Microsoft.PowerShell.Utility/Import-Csv.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md index 4b7649d314f8..3dfc93ea4b44 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md @@ -113,15 +113,16 @@ In this example, the command returns a comma. ### Example 4: Change property names in an imported object ``` -PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv jobs.csv -PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" +PS C:\> Start-Job -Name Jobs -ScriptBlock { Get-Process } | Export-Csv Jobs.csv +PS C:\> Stop-Job -Name Jobs +PS C:\> $Header = "State", "MoreData", "StatusMessage", "Location", "Command", "StateInfo", "Finished", "InstanceId", "Id", "Name", "ChildJobs", "PSBeginTime", "PSEndTime", "PSJobTypeName", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "Information" # Delete header from file -PS C:\> $A = (Get-Content jobs.csv) -PS C:\> $A = $A[0], $A[2..($A.count - 1)] -PS C:\> $A > jobs.csv -PS C:\> $J = Import-Csv jobs.csv -Header $Header +PS C:\> $A = Get-Content Jobs.csv +PS C:\> $A = $A[0], $A[2..($A.Count - 1)] +PS C:\> $A > Jobs.csv +PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J MoreData : True @@ -149,7 +150,7 @@ The first command uses the Start-Job cmdlet to start a background job that runs A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. The second command saves a header in the $Header variable. -Unlike the default header, this header uses MoreData instead of HasMoreData and State instead of JobStateInfo. +Unlike the default header, this header uses MoreData instead of HasMoreData and StateInfo instead of JobStateInfo. The next three commands delete the original header (the second line) from the Jobs.csv file. From 763975833322f882790c11dea8ed2e3d484067e5 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Sat, 27 Jan 2018 13:09:43 -0600 Subject: [PATCH 42/45] update example 4 --- .../Import-Csv.md | 47 ++++++++++--------- .../Import-Csv.md | 43 +++++++++-------- .../Import-Csv.md | 45 +++++++++--------- .../Import-Csv.md | 47 ++++++++++--------- .../Import-Csv.md | 43 +++++++++-------- 5 files changed, 118 insertions(+), 107 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index 3d5a9cef1885..fdc41f3ec41f 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -115,7 +115,7 @@ In this example, the command returns a comma. ### Example 4 ``` PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv -PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" +PS C:\> $Header = "State", "MoreData", "StatusMessage", "Location", "Command", "JobState", "Finished", "InstanceId", "Id", "Name", "ChildJobs", "PSBeginTime", "PSEndTime", "PSJobTypeName", "Output", "Error", "Progress", "Verbose", "Debug", "Warning" # Delete header from file @@ -126,36 +126,39 @@ PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J -MoreData : Running -StatusMessage : True -Location : -Command : localhost -State : Get-Process -Finished : Running -InstanceId : System.Threading.ManualResetEvent -SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f -Name : 3 -ChildJobs : Job3 -Output : System.Collections.Generic.List`1[System.Management.Automation.Job] -Error : 2018-01-25 3:17:34 PM -Progress : -Verbose : BackgroundJob -Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +State : Running +MoreData : True +StatusMessage : +Location : localhost +Command : Get-Process +JobState : Running +Finished : System.Threading.ManualResetEvent +InstanceId : 0971f048-510d-4d53-9b06-c9ee0b91032a +Id : 2 +Name : Jobs +ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] +PSBeginTime : 1/27/2018 6:37:27 PM +PSEndTime : +PSJobTypeName : BackgroundJob +Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +Verbose : System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord] +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord] ``` This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. -The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-CSV cmdlet, which converts the job object to CSV format. An assignment operator (=) saves the resulting CSV in the Jobs.csv file. +The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-CSV cmdlet, which converts the job object to CSV format. -The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "StateInfo" instead of "JobStateInfo". The next three commands delete the original header (the second line) from the Jobs.csv file. -The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $j variable. +The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. -The seventh command displays the object in the $j variable. The resulting object has "MoreData" and "State" properties, as shown in the command output. +The seventh command displays the object in the $J variable. The resulting object has "MoreData" and "StateInfo" properties, as shown in the command output. ### Example 5 ``` diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index d07b3b23afbd..8d66e4fcee7d 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -117,7 +117,7 @@ In this example, the command returns a comma. ### Example 4 ``` PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv -PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" +PS C:\> $Header = "State", "MoreData", "StatusMessage", "Location", "Command", "StateInfo", "Finished", "InstanceId", "Id", "Name", "ChildJobs", "PSBeginTime", "PSEndTime", "PSJobTypeName", "Output", "Error", "Progress", "Verbose", "Debug", "Warning" # Delete header from file @@ -128,36 +128,39 @@ PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J -MoreData : Running -StatusMessage : True -Location : -Command : localhost -State : Get-Process -Finished : Running -InstanceId : System.Threading.ManualResetEvent -SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f -Name : 3 -ChildJobs : Job3 -Output : System.Collections.Generic.List`1[System.Management.Automation.Job] -Error : 2018-01-25 3:17:34 PM -Progress : -Verbose : BackgroundJob -Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +State : Running +MoreData : True +StatusMessage : +Location : localhost +Command : Get-Process +StateInfo : Running +Finished : System.Threading.ManualResetEvent +InstanceId : f5181c45-2927-4936-815b-1e4617b7a873 +Id : 2 +Name : Jobs +ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] +PSBeginTime : 1/27/2018 6:39:41 PM +PSEndTime : +PSJobTypeName : BackgroundJob +Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +Verbose : System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord] +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord] ``` This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-CSV cmdlet, which converts the job object to CSV format. -The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "StateInfo" instead of "JobStateInfo". The next three commands delete the original header (the second line) from the Jobs.csv file. The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. -The seventh command displays the object in the $J variable. The resulting object has "MoreData" and "State" properties, as shown in the command output. +The seventh command displays the object in the $J variable. The resulting object has "MoreData" and "StateInfo" properties, as shown in the command output. ### Example 5 ``` diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 1a66a894d820..2f16ccbc532d 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -107,7 +107,7 @@ In this example, the command returns a comma. ### Example 4: Change property names in an imported object ``` PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv -PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" +PS C:\> $Header = "State", "MoreData", "StatusMessage", "Location", "Command", "JobState", "Finished", "InstanceId", "Id", "Name", "ChildJobs", "PSBeginTime", "PSEndTime", "PSJobTypeName", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "Information" # Delete header from file @@ -118,29 +118,32 @@ PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J -MoreData : Running -StatusMessage : True -Location : -Command : localhost -State : Get-Process -Finished : Running -InstanceId : System.Threading.ManualResetEvent -SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f -Name : 3 -ChildJobs : Job3 -Output : System.Collections.Generic.List`1[System.Management.Automation.Job] -Error : 2018-01-25 3:17:34 PM -Progress : -Verbose : BackgroundJob -Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +State : Running +MoreData : True +StatusMessage : +Location : localhost +Command : Get-Process +JobState : Running +Finished : System.Threading.ManualResetEvent +InstanceId : e6e44f34-c91d-46a6-ad17-ecbdb490a009 +Id : 1 +Name : Jobs +ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] +PSBeginTime : 2018-01-27 11:05:00 AM +PSEndTime :d +PSJobTypeName : BackgroundJob +Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +Verbose : System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord] +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord] +Information : System.Management.Automation.PSDataCollection`1[System.Management.Automation.InformationRecord] ``` This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. -The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. -A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. +The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". @@ -148,7 +151,7 @@ The next three commands delete the original header (the second line) from the Jo The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. -The seventh command displays the object in the $J variable. The resulting object has MoreData and State properties, as shown in the command output. +The seventh command displays the object in the $J variable. The resulting object has "MoreData" and "StateInfo" properties, as shown in the command output. ### Example 5: Create a custom object using a CSV file ``` diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 4cc398b56f1f..0428cc701d1a 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -119,7 +119,7 @@ In this example, the command returns a comma. ### Example 4: Change property names in an imported object ``` PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv -PS C:\> $Header = "MoreData", "StatusMessage", "Location", "Command", "State", "Finished", "InstanceId", "SessionId", "Name", "ChildJobs", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "StateChanged" +PS C:\> $Header = "State", "MoreData", "StatusMessage", "Location", "Command", "JobState", "Finished", "InstanceId", "Id", "Name", "ChildJobs", "PSBeginTime", "PSEndTime", "PSJobTypeName", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "Information" # Delete header from file @@ -130,37 +130,40 @@ PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J -MoreData : Running -StatusMessage : True -Location : -Command : localhost -State : Get-Process -Finished : Running -InstanceId : System.Threading.ManualResetEvent -SessionId : 12bf8fae-4575-4041-a68e-23220b7d486f -Name : 3 -ChildJobs : Job3 -Output : System.Collections.Generic.List`1[System.Management.Automation.Job] -Error : 2018-01-25 3:17:34 PM -Progress : -Verbose : BackgroundJob -Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] -Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] -StateChanged : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +State : Running +MoreData : True +StatusMessage : +Location : localhost +Command : Get-Process +JobState : Running +Finished : System.Threading.ManualResetEvent +InstanceId : e6e44f34-c91d-46a6-ad17-ecbdb490a009 +Id : 1 +Name : Jobs +ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] +PSBeginTime : 2018-01-27 11:05:00 AM +PSEndTime :d +PSJobTypeName : BackgroundJob +Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] +Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] +Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] +Verbose : System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord] +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord] +Information : System.Management.Automation.PSDataCollection`1[System.Management.Automation.InformationRecord] ``` This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. -The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. -A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. +The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. -The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "State" instead of "JobStateInfo". +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "StateInfo" instead of "JobStateInfo". The next three commands delete the original header (the second line) from the Jobs.csv file. The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. -The seventh command displays the object in the $J variable. The resulting object has MoreData and State properties, as shown in the command output. +The seventh command displays the object in the $J variable. The resulting object has "MoreData" and "StateInfo" properties, as shown in the command output. ### Example 5: Create a custom object using a CSV file ``` diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md index 3dfc93ea4b44..9b8cc2c57b69 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md @@ -113,53 +113,52 @@ In this example, the command returns a comma. ### Example 4: Change property names in an imported object ``` -PS C:\> Start-Job -Name Jobs -ScriptBlock { Get-Process } | Export-Csv Jobs.csv -PS C:\> Stop-Job -Name Jobs +PS C:\> Start-Job -ScriptBlock { Get-Process } | Export-Csv Jobs.csv PS C:\> $Header = "State", "MoreData", "StatusMessage", "Location", "Command", "StateInfo", "Finished", "InstanceId", "Id", "Name", "ChildJobs", "PSBeginTime", "PSEndTime", "PSJobTypeName", "Output", "Error", "Progress", "Verbose", "Debug", "Warning", "Information" # Delete header from file PS C:\> $A = Get-Content Jobs.csv -PS C:\> $A = $A[0], $A[2..($A.Count - 1)] +PS C:\> $A = $A[1..($A.Count - 1)] PS C:\> $A > Jobs.csv PS C:\> $J = Import-Csv Jobs.csv -Header $Header PS C:\> $J + +State : Running MoreData : True StatusMessage : Location : localhost -Command : get-process -State : Running +Command : Get-Process +StateInfo : Running Finished : System.Threading.ManualResetEvent -InstanceId : 135bdd25-40d6-4a20-bd68-05282a59abd6 -SessionId : 1 -Name : Job1 +InstanceId : c41e709b-80e4-4f15-ad5f-75d1548c6b7c +Id : 1 +Name : Jobs ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] +PSBeginTime : 2018-01-27 1:03:00 PM +PSEndTime : +PSJobTypeName : BackgroundJob Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] -Verbose : System.Management.Automation.PSDataCollection`1[System.String] -Debug : System.Management.Automation.PSDataCollection`1[System.String] -Warning : System.Management.Automation.PSDataCollection`1[System.String] -StateChanged : +Verbose : System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord] +Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord] +Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord] +Information : System.Management.Automation.PSDataCollection`1[System.Management.Automation.InformationRecord] ``` This example shows how to use the *Header* parameter of **Import-Csv** to change the names of properties in the resulting imported object. -The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. -A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. +The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. A pipeline operator (|) sends the resulting job object to the Export-Csv cmdlet, which converts the job object to CSV format. -The second command saves a header in the $Header variable. -Unlike the default header, this header uses MoreData instead of HasMoreData and StateInfo instead of JobStateInfo. +The second command saves a header in the $Header variable. Unlike the default header, this header uses "MoreData" instead of "HasMoreData" and "StateInfo" instead of "JobStateInfo". -The next three commands delete the original header (the second line) from the Jobs.csv file. +The next three commands delete the original header (the first line) from the Jobs.csv file. -The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. -The command uses the *Header* parameter to submit the alternate header. -The results are stored in the $J variable. +The sixth command uses the **Import-Csv** cmdlet to import the Jobs.csv file and convert the CSV strings into a CSV version of the job object. The command uses the *Header* parameter to submit the alternate header. The results are stored in the $J variable. -The seventh command displays the object in the $J variable. -The resulting object has MoreData and State properties, as shown in the command output. +The seventh command displays the object in the $J variable. The resulting object has "MoreData" and "StateInfo" properties, as shown in the command output. ### Example 5: Create a custom object using a CSV file ``` From 33c6a1c70e25fb782e45bb0fc25fd4d089678f61 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Sat, 27 Jan 2018 13:18:37 -0600 Subject: [PATCH 43/45] update example 5 --- .../Import-Csv.md | 9 ++- .../Import-Csv.md | 9 ++- .../Import-Csv.md | 7 +-- .../Import-Csv.md | 7 +-- .../Import-Csv.md | 63 ++++++++++--------- 5 files changed, 48 insertions(+), 47 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index fdc41f3ec41f..acbeae15bbfb 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -191,7 +191,6 @@ GetType Method type GetType() ToString Method string ToString() LinkID NoteProperty string LinkID=113207 TopicTitle NoteProperty string TopicTitle=about_Aliases - PS C:\> $A | Where-Object TopicTitle -Like "*alias*" LinkID TopicTitle @@ -203,15 +202,15 @@ This example shows how to create a custom object in Windows PowerShell by using The first command uses the Get-Content cmdlet to get the Links.csv file. -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $a variable. +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify "LinkId" and "TopicTitle" as property names for the new custom objects. The command saves the imported objects in the $A variable. -The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $a variable. +The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $A variable. -The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have "LinkId" and "TopicTitle" note properties. This command shows that you can use the custom object like you would any object in Windows PowerShell. -The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a "TopicTitle" property that includes "alias". The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 8d66e4fcee7d..5453e5fd4c1d 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -193,7 +193,6 @@ GetType Method type GetType() ToString Method string ToString() LinkID NoteProperty string LinkID=113207 TopicTitle NoteProperty string TopicTitle=about_Aliases - PS C:\> $A | Where-Object TopicTitle -Like "*alias*" LinkID TopicTitle @@ -205,15 +204,15 @@ This example shows how to create a custom object in Windows PowerShell by using The first command uses the Get-Content cmdlet to get the Links.csv file. -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $a variable. +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify "LinkId" and "TopicTitle" as property names for the new custom objects. The command saves the imported objects in the $A variable. -The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $a variable. +The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $A variable. -The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have "LinkId" and "TopicTitle" note properties. This command shows that you can use the custom object like you would any object in Windows PowerShell. -The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a "TopicTitle" property that includes "alias". The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index 2f16ccbc532d..d2ea7b380514 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -184,7 +184,6 @@ GetType Method type GetType() ToString Method string ToString() LinkID NoteProperty string LinkID=113207 TopicTitle NoteProperty string TopicTitle=about_Aliases - PS C:\> $A | Where-Object TopicTitle -Like "*alias*" LinkID TopicTitle @@ -196,15 +195,15 @@ This example shows how to create a custom object in Windows PowerShell by using The first command uses the Get-Content cmdlet to get the Links.csv file. -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $A variable. +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify "LinkId" and "TopicTitle" as property names for the new custom objects. The command saves the imported objects in the $A variable. The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $A variable. -The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have "LinkId" and "TopicTitle" note properties. This command shows that you can use the custom object like you would any object in Windows PowerShell. -The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a "TopicTitle" property that includes "alias". The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 0428cc701d1a..106d7f9d283d 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -196,7 +196,6 @@ GetType Method type GetType() ToString Method string ToString() LinkID NoteProperty string LinkID=113207 TopicTitle NoteProperty string TopicTitle=about_Aliases - PS C:\> $A | Where-Object TopicTitle -Like "*alias*" LinkID TopicTitle @@ -208,15 +207,15 @@ This example shows how to create a custom object in Windows PowerShell by using The first command uses the Get-Content cmdlet to get the Links.csv file. -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. The command saves the imported objects in the $A variable. +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify "LinkId" and "TopicTitle" as property names for the new custom objects. The command saves the imported objects in the $A variable. The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $A variable. -The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have "LinkId" and "TopicTitle" note properties. This command shows that you can use the custom object like you would any object in Windows PowerShell. -The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a TopicTitle property that includes "alias". +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a "TopicTitle" property that includes "alias". The **Where-Object** command uses the new simplified command format that does not require symbols, script blocks, or curly braces. diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md index 9b8cc2c57b69..1dc81d8a1717 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md @@ -163,49 +163,54 @@ The seventh command displays the object in the $J variable. The resulting object ### Example 5: Create a custom object using a CSV file ``` PS C:\> Get-Content .\Links.csv -113207,about_Aliases113208,about_Arithmetic_Operators113209,about_Arrays113210,about_Assignment_Operators113212, -about_Automatic_Variables113213,about_Break113214,about_Command_Precedence113215,about_Command_Syntax144309, -about_Comment_Based_Help113216,about_CommonParameters113217,about_Comparison_Operators113218,about_Continue113219, -about_Core_Commands113220,about_Data_Section… PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle +113207,about_Aliases +113208,about_Arithmetic_Operators +113209,about_Arrays +113210,about_Assignment_Operators +113212,about_Automatic_Variables +113213,about_Break +113214,about_Command_Precedence +113215,about_Command_Syntax +144309,about_Comment_Based_Help +113216,about_CommonParameters +113217,about_Comparison_Operators +113218,about_Continue +113219,about_Core_Commands +113220,about_Data_Section +PS C:\> $A = Import-Csv -Path .\Links.csv -Header LinkID, TopicTitle PS C:\> $A | Get-Member + + TypeName: System.Management.Automation.PSCustomObject -Name MemberType Definition ----- ---------- ---------- -Equals Method bool -Equals(System.Object obj) -GetHashCode Method int -GetHashCode()GetType Method type -GetType()ToString Method string -ToString()LinkID NoteProperty System.String -LinkID=113207TopicTitle NoteProperty System.String -TopicTitle=about_Aliases PS C:\> $A | Where-Object TopicTitle -Like "*alias*" -LinkID TopicTitle ------- ---------- -113207 about_Aliases -113432 Alias Provider -113296 Export-Alias -113306 Get-Alias -113339 Import-Alias -113352 New-Alias -113390 Set-Alias + +Name MemberType Definition +---- ---------- ---------- +Equals Method bool Equals(System.Object obj) +GetHashCode Method int GetHashCode() +GetType Method type GetType() +ToString Method string ToString() +LinkID NoteProperty string LinkID=113207 +TopicTitle NoteProperty string TopicTitle=about_Aliases +PS C:\> $A | Where-Object TopicTitle -Like "*alias*" + +LinkID TopicTitle +------ ---------- +113207 about_Aliases ``` This example shows how to create a custom object in Windows PowerShell by using a CSV file. The first command uses the Get-Content cmdlet to get the Links.csv file. -The second command uses the **Import-Csv** cmdlet to import the Links.csv file. -The command uses the *Header* parameter to specify LinkId and TopicTitle as property names for the new custom objects. -The command saves the imported objects in the $A variable. +The second command uses the **Import-Csv** cmdlet to import the Links.csv file. The command uses the *Header* parameter to specify "LinkId" and "TopicTitle" as property names for the new custom objects. The command saves the imported objects in the $A variable. The third command uses the Get-Member cmdlet to get the type and members of the custom objects in the $A variable. -The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). -In addition to some default properties, the custom objects have LinkID and TopicTitle note properties. +The output shows that **Import-Csv** returns a collection of custom objects (**PSCustomObject**). In addition to some default properties, the custom objects have "LinkId" and "TopicTitle" note properties. This command shows that you can use the custom object like you would any object in Windows PowerShell. -The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a **TopicTitle** property that includes alias. +The command pipes the custom objects in the $A variable to the **Where-Object** cmdlet, which gets only objects with a "TopicTitle" property that includes "alias". The Where-Object command uses the new simplified command format that does not require symbols, script blocks, or curly braces. From 671f9850efae19ae41cfad4e2c4dce5eaeb58fd2 Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Sat, 27 Jan 2018 13:38:23 -0600 Subject: [PATCH 44/45] 6.0 example 6 and parameter format --- .../Import-Csv.md | 113 ++++++++---------- 1 file changed, 51 insertions(+), 62 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md index 1dc81d8a1717..74d51d530154 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Csv.md @@ -217,36 +217,48 @@ The Where-Object command uses the new simplified command format that does not re ### Example 6: Import a CSV that is missing a value ``` PS C:\> Get-Content "\\Server2\c$\Test\Projects.csv" -ProjectID, ProjectName,,Completed, Inventory, Redmond, True440, , FarEast, True, Marketing, Europe, False PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -PS C:\> WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. -ProjectID ProjectName H1 Completed ---------- ----------- -- --------- -13 Inventory Redmond True -440 FarEast True -469 Marketing Europe False PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 -RedmondFarEastEurope +ProjectID,ProjectName,,Completed +13,Inventory,Redmond,True +440,,FarEast,True +469,Marketing,Europe,False +PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. + +ProjectID ProjectName H1 Completed +--------- ----------- -- --------- +13 Inventory Redmond True +440 FarEast True +469 Marketing Europe False + +PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +Redmond +FarEast +Europe ``` -This example shows how the **Import-Csv** cmdlet in Windows PowerShell 3.0 responds when the header row in a CSV file includes a null or empty value. -**Import-Csv** substitutes a default name for the header row. -The default name becomes the name of the property of the object that **Import-Csv** returns. +This example shows how the **Import-Csv** cmdlet in PowerShell responds when the header row in a CSV file includes a null or empty value. -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. -The output shows that the header row of the file is missing a value between ProjectName and Completed. +**Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. + +The first command uses the Get-Content cmdlet to get the Projects.csv file on the "Server02" remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. -The output shows that **Import-Csv** generates a warning and substitutes a default name, H1, for the missing header row value. -H1 is also used for the name of the object property. +The output shows that **Import-Csv** generates a warning and substitutes a default name, "H1", for the missing header row value. +"H1" is also used for the name of the object property. -The third command uses the dot method to get the value of the H1 property of the object that **Import-Csv** creates. +The third command uses the dot method to get the value of the "H1" property of the object that **Import-Csv** creates. ## PARAMETERS ### -Delimiter Specifies the delimiter that separates the property values in the CSV file. + The default is a comma (,). + Enter a character, such as a colon (:). + To specify a semicolon (;), enclose it in quotation marks. If you specify a character other than the actual string delimiter in the file, **Import-Csv** cannot create objects from the CSV strings. @@ -266,6 +278,7 @@ Accept wildcard characters: False ### -Encoding Specifies the type of character encoding that was used in the CSV file. + The acceptable values for this parameter are: - Unicode @@ -295,17 +308,19 @@ Accept wildcard characters: False ``` ### -Header -Specifies an alternate column header row for the imported file. -The column header determines the names of the properties of the object that **Import-Csv** creates. +Specifies an alternate column header row for the imported file. The column header determines the names of the properties of the object that **Import-Csv** creates. Enter a comma-separated list of the column headers. + Enclose each item in quotation marks (single or double). + Do not enclose the header string in quotation marks. + If you enter fewer column headers than there are columns, the remaining columns will have no header. + If you enter more headers than there are columns, the extra headers are ignored. -When using the *Header* parameter, delete the original header row from the CSV file. -Otherwise, **Import-Csv** creates an extra object from the items in the header row. +When using the *Header* parameter, delete the original header row from the CSV file. Otherwise, **Import-Csv** creates an extra object from the items in the header row. ```yaml Type: String[] @@ -319,35 +334,28 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -InformationAction -If you specify a character other than the actual string delimiter in the file, Import-Csv cannot create objects from the CSV strings. Instead, it returns the strings.```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: infa -Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend +### -LiteralPath +Specifies the path to the CSV file to import. -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` +Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. -### -InformationVariable -If you specify a character other than the actual string delimiter in the file, Import-Csv cannot create objects from the CSV strings. Instead, it returns the strings.```yaml -Type: String +If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences. + +```yaml +Type: String[] Parameter Sets: (All) -Aliases: iv +Aliases: PSPath Required: False Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` ### -Path Specifies the path to the CSV file to import. + You can also pipe a path to **Import-Csv**. ```yaml @@ -364,11 +372,10 @@ Accept wildcard characters: False ### -UseCulture Indicates that this cmdlet uses the list separator for the current culture as the item delimiter. -The default is a comma (,). + +The default is based on the culture settings of the Operating System (e.g. en-US culture will return a comma (,) by default). To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. -If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-Csv cannot create objects from the CSV strings. -Instead, it returns the strings. ```yaml Type: SwitchParameter @@ -382,25 +389,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -LiteralPath -Specifies the path to the CSV file to import. -Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. -No characters are interpreted as wildcards. -If the path includes escape characters, enclose it in single quotation marks. -Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: PSPath - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). @@ -415,10 +403,10 @@ You can pipe a string that contains a path to **Import-Csv**. This cmdlet returns the objects described by the content in the CSV file. ## NOTES -* Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the Windows PowerShell type formatting entries that format the non-CSV versions of the object type. -* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the **Count** property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. +* Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the PowerShell type formatting entries that format the non-CSV versions of the object type. +* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the *Count* property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. * The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the *Header* parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. -* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses H followed by a number for the missing column header and property name. +* If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. * In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-Csv does not export the methods of the object. ## RELATED LINKS @@ -429,3 +417,4 @@ This cmdlet returns the objects described by the content in the CSV file. [Export-Csv](Export-Csv.md) +[Get-Culture](Get-Culture.md) \ No newline at end of file From 62794a0da9a3ff71f4c4a87fa6fd940c9336255e Mon Sep 17 00:00:00 2001 From: Shawn Melton Date: Sat, 27 Jan 2018 13:38:44 -0600 Subject: [PATCH 45/45] addtional touchups on format --- .../Import-Csv.md | 22 +++++++++---------- .../Import-Csv.md | 22 +++++++++---------- .../Import-Csv.md | 8 ++----- .../Import-Csv.md | 8 ++----- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md index acbeae15bbfb..2eb63965b7c9 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -222,13 +222,14 @@ ProjectID,ProjectName,,Completed 440,,FarEast,True 469,Marketing,Europe,False PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing + headers. -ProjectID ProjectName H1 Completed ---------- ----------- -- --------- -13 Inventory Redmond True -440 FarEast True -469 Marketing Europe False +ProjectID ProjectName H1 Completed +--------- ----------- -- --------- +13 Inventory Redmond True +440 FarEast True +469 Marketing Europe False PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 @@ -242,7 +243,7 @@ This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds **Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." +The first command uses the Get-Content cmdlet to get the Projects.csv file on the "Server02" remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. @@ -376,9 +377,6 @@ The default is based on the culture settings of the Operating System (e.g. en-US To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. -If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-CSV cannot create objects from the CSV strings. -Instead, it returns the strings. - ```yaml Type: SwitchParameter Parameter Sets: UseCulture @@ -406,8 +404,8 @@ This cmdlet returns the objects described by the content in the CSV file. ## NOTES * Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the Windows PowerShell type formatting entries that format the non-CSV versions of the object type. -* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the Count property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. -* The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the Header parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. +* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the *Count* property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. +* The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the *Header* parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. * If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. * In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-CSV does not export the methods of the object. diff --git a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md index 5453e5fd4c1d..4862146443cb 100644 --- a/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/4.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -224,13 +224,14 @@ ProjectID,ProjectName,,Completed 440,,FarEast,True 469,Marketing,Europe,False PS C:\> Import-Csv "\\Server2\c$\Test\Projects.csv" -WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. +WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing + headers. -ProjectID ProjectName H1 Completed ---------- ----------- -- --------- -13 Inventory Redmond True -440 FarEast True -469 Marketing Europe False +ProjectID ProjectName H1 Completed +--------- ----------- -- --------- +13 Inventory Redmond True +440 FarEast True +469 Marketing Europe False PS C:\> (Import-Csv "\\Server2\c$\Test\Projects.csv").H1 @@ -244,7 +245,7 @@ This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds **Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." +The first command uses the Get-Content cmdlet to get the Projects.csv file on the "Server02" remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. @@ -378,9 +379,6 @@ The default is based on the culture settings of the Operating System (e.g. en-US To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. -If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-CSV cannot create objects from the CSV strings. -Instead, it returns the strings. - ```yaml Type: SwitchParameter Parameter Sets: UseCulture @@ -408,8 +406,8 @@ This cmdlet returns the objects described by the content in the CSV file. ## NOTES * Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the Windows PowerShell type formatting entries that format the non-CSV versions of the object type. -* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the Count property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. -* The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the Header parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. +* The result of an **Import-Csv** command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the *Count* property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values. +* The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the *Header* parameter to specify column headers. If any row has more values than the header row, the additional values are ignored. * If the column header row is missing a value or contains a null or empty value, **Import-Csv** uses "H" followed by a number for the missing column header and property name. * In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-CSV does not export the methods of the object. diff --git a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md index d2ea7b380514..cfbd3b650af1 100644 --- a/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.0/Microsoft.PowerShell.Utility/Import-Csv.md @@ -233,10 +233,9 @@ Europe This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds when the header row in a CSV file includes a null or empty value. -**Import-Csv** substitutes a default name for the header row. -The default name becomes the name of the property of the object that **Import-Csv** returns. +**Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed". +The first command uses the Get-Content cmdlet to get the Projects.csv file on the "Server02" remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. @@ -371,9 +370,6 @@ The default is based on the culture settings of the Operating System (e.g. en-US To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. -If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-Csv cannot create objects from the CSV strings. -Instead, it returns the strings. - ```yaml Type: SwitchParameter Parameter Sets: UseCulture diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md index 106d7f9d283d..5ca8d6bfe10a 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Import-Csv.md @@ -247,7 +247,7 @@ This example shows how the **Import-Csv** cmdlet in Windows PowerShell responds **Import-Csv** substitutes a default name for the header row. The default name becomes the name of the property of the object that **Import-Csv** returns. -The first command uses the Get-Content cmdlet to get the Projects.csv file on the Server02 remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed". +The first command uses the Get-Content cmdlet to get the Projects.csv file on the "Server02" remote computer. The output shows that the header row of the file is missing a value between "ProjectName" and "Completed." The second command uses the **Import-Csv** cmdlet to import the Projects.csv file. @@ -344,8 +344,7 @@ Specifies the path to the CSV file to import. Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed. No characters are interpreted as wildcards. -If the path includes escape characters, enclose it in single quotation marks. -Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. +If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. ```yaml Type: String[] @@ -383,9 +382,6 @@ The default is based on the culture settings of the Operating System (e.g. en-US To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`. -If you specify a character other than the delimiter used in the CSV strings, ConvertFrom-Csv cannot create objects from the CSV strings. -Instead, it returns the strings. - ```yaml Type: SwitchParameter Parameter Sets: UseCulture