I'm new to Powershell, i am working with the basics. If someone could try provide an example of;
A function to get contents of a folder (get-childitem -Path c:\temp | Select-Object Name, Length) and puts them into an array of arrays -- array=@()
The script body should then output what is returned from the function. I can use a for loop to make a table format of my array which is ok.
I believe a variable scope comes in here, to return the contents of an array?
In simple terms the Function needs to do something, and outside of the function needs a variable scope to retain what get-childitem returns.
So output needs to be called outside of the function.
Example: Function - Get-childItem - Store Data in Array Call Function to Output Data in Array.
function GCI{get-childitem -Path c:\temp | Select-Object Name, Length}would return an array (if there is more that one result also depends on your PowerShell version)