![]() ![]() ![]() $fso = new-object -ComObject scripting.filesystemobject An example of using this object is shown here. An object returns, which contains the path and other information about the newly created folder. The CreateFolder method accepts a string that represents the path to create the folder. After it is created, Scripting.FilesystemObject exposes a CreateFolder method. It is extremely fast, and relatively easy to use. This is the same object that VBScript and other scripting languages use to work with the file system. Method 2Īnother way to create a folder is to use the Scripting.FileSystemObject object from within Windows PowerShell. NET Framework classes from within Windows PowerShell. NET Framework Classes from Within PowerShell Hey, Scripting Guy! blog for more information about when to use and not to use. I do not necessarily recommend this approach, but it is available. The command and its associated output are shown in the image that follows. When the command runs, it returns a DirectoryInfo class. To use the Directory class to create a new folder, use the CreateDirectory static method and supply a path that points to the location where the new folder is to reside. NET Framework class from the system.io namespace. GW, you are correct, there are lots of ways to create directories, and I will show you four of them… Method 1 (New-TimeSpan -Start 2/21/12 -End 4/2/12).daysīoth of these commands and the associated output are shown in the image that follows. I decided I would like a cleaner output, so I used one of my Top Ten Favorite Windows PowerShell Tricks: group and dot. Sure enough, the returned TimeSpan object tells me that there are indeed 41 days until the 2012 Scripting Games. ![]() I fired up Windows PowerShell and typed the following code: Even though I have been busily working away on the Scripting Games, it seems awfully soon. This morning on Twitter, I saw a tweet that said “New-TimeSpan tells me that there are 41 days until the 2012 Scripting Games.” Indeed. Microsoft Scripting Guy, Ed Wilson, is here. Is there a best way to create a new folder? They all seem to use something different. I have seen many ways of creating folders in scripts that I have run across on the Internet. Hey, Scripting Guy! I am trying to find the best way to create a new folder while using Windows PowerShell. Summary: Microsoft Scripting Guy, Ed Wilson, shows four ways to create folders with Windows PowerShell, and he discusses the merits of each approach. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |