This works well enough. The results include the names of the folder being created, the servers where these folders are created and the data and time the folders are created.
I then use the code below to remove the folders I have just created.
It completed the task but does not provide any sort of confirmation. While I understand that no news is good news, what if I want to get some sort of confirmation on screen so I can choose to write it into an output file if needed? How would I do that? I tried adding “-verbose” at the end but it made no difference.
My goal is read in a list of servers from a text file or csv file and perform some tasks (such as simply creating a new directory or something far more complicated). At the end of the process, I would like the results of the process to be written back to the input file so I would have something like this:
This is what I have come up so far. It is reading from the CSV file correctly but not updating the Status column correctly. The CSV file only has two columns: ServerName and Status.
Ted, in the future I’d recommend using standard formatting approaches to your script.
Formatting makes code much easier to troubleshoot, especially when others need to read your code to attempt to help.
I ran the code and this is what I get in the ServerListWithStatus.csv file.
#TYPE System.Management.Automation.PSCustomObject
ServerName
Status
System.Object[]
System.Object[]
System.Object[]
System.Object[]
System.Object[]
System.Object[]
So it looks like we are now on the right trace. I have three rows of data and the script is writing three rows of data. Thinking I need to convert the object back to string, I modified the last line of code to this