![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Create a folder on a remote machine? Hi, Is there a way to create a folder on a remote machine using PowerShell (not FileSystemObject), e.g. create a new folder "D:\My Folder". <if possible> It should not rely on UNC paths, because it's part of a bigger program that needs to continue running if there's a network outage. Thanks. -- Gerry Hickman (London UK) |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Create a folder on a remote machine? If you are running PowerShell V2 CTP then you could use the remoting facilities. otherwise you could use WMI $computer = "." $p = [WMIClass]"\\$computer\root\cimv2:Win32_Process" $p.Create("cmd.exe /c md c:\test452") replace the . with the computer name in $computer = "." and put the folder name you need into the create statement -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Gerry Hickman" wrote: Quote: > Hi, > > Is there a way to create a folder on a remote machine using PowerShell > (not FileSystemObject), e.g. create a new folder "D:\My Folder". > > <if possible> > > It should not rely on UNC paths, because it's part of a bigger program > that needs to continue running if there's a network outage. > > Thanks. > > -- > Gerry Hickman (London UK) > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Create a folder on a remote machine? Hi, Quote: > If you are running PowerShell V2 CTP then you could use the remoting > facilities. otherwise you could use WMI just a rough example. Quote: > $computer = "." > $p = [WMIClass]"\\$computer\root\cimv2:Win32_Process" > $p.Create("cmd.exe /c md c:\test452") RetVal are NOT referenced the calling process. Obviously I want the RetVal from the CreateFolder call, plus any error messages, plus a handle to the newly created folder. I was hoping for some professional grade PowerShell answers. I though PowerShell was going to replace CMD.exe? Having read about how "powerful" it is, and how it's a "shell". It's a joke if we have to shell out to the old CMD.exe for such a simple task. It's also a bit strange that we keep hearing about how PowerShell is so "Powerful" with it's calls to .NET, and yet every non-beginner post keeps jumping back to using WMI which is actually the old COM technology. -- Gerry Hickman (London UK) |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Create a folder on a remote machine? Quote: > It's also a bit strange that we keep hearing about how PowerShell is so > "Powerful" with it's calls to .NET, and yet every non-beginner post > keeps jumping back to using WMI which is actually the old COM technology. > > -- > Gerry Hickman (London UK) How odd! WMI was good (new?) enough in your post 2 hours ago to microsoft.public.adsi.general:- <<SNIP>> Bear in mind none of this will work with IIS7, they took out the ADSI so it's best to look to new ways of doing it anyway (maybe WMI?) <<SNIP>> What you get from Rich S is about as "Professional Grade" as it gets. I on the other hand am anything but "Professional Grade", but even I can see that given the parameters you provided in your OP the response was fit for purpose and did not deserve your inelegant response. Hope you get the answer your looking for though! Kind regards, -- Stuart |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Create a folder on a remote machine? On Mar 16, 3:35*pm, Gerry Hickman <gerry66...@xxxxxx> wrote: Quote: > Hi, > Quote: > > If you are running PowerShell V2 CTP then you could use the remoting > > facilities. * otherwise you could use WMI > What is the syntax I'd use with V2 CTP? I don't mean the exact code, > just a rough example. > Quote: > > $computer = "." > > $p = [WMIClass]"\\$computer\root\cimv2:Win32_Process" > > $p.Create("cmd.exe /c md c:\test452") > No, no, no! This is clueless! It starts a process who's output and > RetVal are NOT referenced the calling process. Obviously I want the > RetVal from the CreateFolder call, plus any error messages, plus a > handle to the newly created folder. > > I was hoping for some professional grade PowerShell answers. > > I though PowerShell was going to replace CMD.exe? Having read about how > "powerful" it is, and how it's a "shell". It's a joke if we have to > shell out to the old CMD.exe for such a simple task. > > It's also a bit strange that we keep hearing about how PowerShell is so > "Powerful" with it's calls to .NET, and yet every non-beginner post > keeps jumping back to using WMI which is actually the old COM technology. > > -- > Gerry Hickman (London UK) Despite what its MS marketing droid bestowed "marquee name" implies with the hyperbolous prefix, Powershell is not magic. It is a framework, a shell and a scripting language that is designed to abstract out the differing APIs on the windows platform such as WMI, COM, .NET etc. Yes, it comes with a handful of built-in cmdlets, and perhaps they are lacking a fair chunk of functionality for v1, but this is by-design. Great extensibility is a better goal for an initial release than an inextensible and purely subjective view of what they felt would be "feature complete" for functionality. I'm sorry if you're having a hard time understanding what the product is and does -- and clearly you are having a hard time -- but hurling insults and calling people clueless will not get you any help, or sympathy for that matter. Ultimately, powerSHELL is a shell. It's job is to allow you to manipulate external services like WMI. It doesn't try to replace it, on the contrary - it is designed to make it easier to use WMI. RichS's solution is perfectly valid. The irony is, if such a "remote folder creation" cmdlet is ever implemented for powershell in the future, it will most likely use COM and/or WMI to do it. Do bash, tcsh, ksh implement internal magic such as what you're suggesting for powershell? No, they do not. They provide a way to execute and manipulate 3rd party executables and leverage CIFS through UNC paths. What you are asking for is not within a reasonable expectations for a "shell." If you don't want to end up in any more killfiles, I suggest you tone down your rhetoric and start reading here: http://www.microsoft.com/windowsserv...l/default.mspx - Oisin |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Create a folder on a remote machine? You guys way over think this stuff ![]() new-item \\$computer\c$\FolderName -itemType Directory "RichS" <RichS@xxxxxx> wrote in message news:B58F5F2B-7D9C-44EB-8599-A55C9CBCAB25@xxxxxx Quote: > If you are running PowerShell V2 CTP then you could use the remoting > facilities. otherwise you could use WMI > > $computer = "." > $p = [WMIClass]"\\$computer\root\cimv2:Win32_Process" > $p.Create("cmd.exe /c md c:\test452") > > replace the . with the computer name in $computer = "." > > and put the folder name you need into the create statement > > -- > Richard Siddaway > Please note that all scripts are supplied "as is" and with no warranty > Blog: http://richardsiddaway.spaces.live.com/ > PowerShell User Group: http://www.get-psuguk.org.uk > > > "Gerry Hickman" wrote: > Quote: >> Hi, >> >> Is there a way to create a folder on a remote machine using PowerShell >> (not FileSystemObject), e.g. create a new folder "D:\My Folder". >> >> <if possible> >> >> It should not rely on UNC paths, because it's part of a bigger program >> that needs to continue running if there's a network outage. >> >> Thanks. >> >> -- >> Gerry Hickman (London UK) >> |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Create a folder on a remote machine? See my example. It is one line and returns a system.io.directoryinfo object "Gerry Hickman" <gerry666uk@xxxxxx> wrote in message news:ueIMmz5hIHA.4320@xxxxxx Quote: > Hi, > Quote: >> If you are running PowerShell V2 CTP then you could use the remoting >> facilities. otherwise you could use WMI > What is the syntax I'd use with V2 CTP? I don't mean the exact code, just > a rough example. > Quote: >> $computer = "." >> $p = [WMIClass]"\\$computer\root\cimv2:Win32_Process" >> $p.Create("cmd.exe /c md c:\test452") > No, no, no! This is clueless! It starts a process who's output and RetVal > are NOT referenced the calling process. Obviously I want the RetVal from > the CreateFolder call, plus any error messages, plus a handle to the newly > created folder. > > I was hoping for some professional grade PowerShell answers. > > I though PowerShell was going to replace CMD.exe? Having read about how > "powerful" it is, and how it's a "shell". It's a joke if we have to shell > out to the old CMD.exe for such a simple task. > > It's also a bit strange that we keep hearing about how PowerShell is so > "Powerful" with it's calls to .NET, and yet every non-beginner post keeps > jumping back to using WMI which is actually the old COM technology. > > -- > Gerry Hickman (London UK) |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Create a folder on a remote machine? This was brought up in a side bar. So for clarity. I ignored the UNC restriction purposely. If you lose your network... aint nothing gonna work. "Brandon Shell [MVP]" <tshell._rem_@xxxxxx> wrote in message news:41922DAE-7989-4FA0-B620-946876BD603A@xxxxxx Quote: > You guys way over think this stuff ![]() > > new-item \\$computer\c$\FolderName -itemType Directory > > "RichS" <RichS@xxxxxx> wrote in message > news:B58F5F2B-7D9C-44EB-8599-A55C9CBCAB25@xxxxxx Quote: >> If you are running PowerShell V2 CTP then you could use the remoting >> facilities. otherwise you could use WMI >> >> $computer = "." >> $p = [WMIClass]"\\$computer\root\cimv2:Win32_Process" >> $p.Create("cmd.exe /c md c:\test452") >> >> replace the . with the computer name in $computer = "." >> >> and put the folder name you need into the create statement >> >> -- >> Richard Siddaway >> Please note that all scripts are supplied "as is" and with no warranty >> Blog: http://richardsiddaway.spaces.live.com/ >> PowerShell User Group: http://www.get-psuguk.org.uk >> >> >> "Gerry Hickman" wrote: >> Quote: >>> Hi, >>> >>> Is there a way to create a folder on a remote machine using PowerShell >>> (not FileSystemObject), e.g. create a new folder "D:\My Folder". >>> >>> <if possible> >>> >>> It should not rely on UNC paths, because it's part of a bigger program >>> that needs to continue running if there's a network outage. >>> >>> Thanks. >>> >>> -- >>> Gerry Hickman (London UK) >>> |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Create a folder on a remote machine? Hi Brandon, Quote: > This was brought up in a side bar. So for clarity. > > I ignored the UNC restriction purposely. If you lose your network... > aint nothing gonna work. unexpected, such as resume after power failure. One of the reasons for wanting to do it without UNC is that my project is a large batch job that runs unattended, it's quite possible some servers will be rebooted while the job is running, it's therefore important that my job runs "locally" (albeit on the remote machine). Actually this is quite common. Most Microsoft technology is designed to work this way (e.g. Windows Update, Vista SP1 etc). So, do you have a PowerShell/.NET means of creating a folder on a remote machine? -- Gerry Hickman (London UK) |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Create a folder on a remote machine? Hi Oisin, Quote: > Despite what its MS marketing droid bestowed "marquee name" implies > with the hyperbolous prefix, Quote: > Powershell is not magic. It is a > framework, a shell and a scripting language that is designed to > abstract out the differing APIs on the windows platform such as WMI, > COM, .NET etc. Yes, it comes with a handful of built-in cmdlets, and > perhaps they are lacking a fair chunk of functionality for v1, but > this is by-design. I'm interested in how to make it WORK, NOT excuses about why it doesn't. Quote: > Great extensibility is a better goal for an initial > release than an inextensible and purely subjective view of what they > felt would be "feature complete" for functionality. above! Quote: > I'm sorry if > you're having a hard time understanding what the product is and does > -- and clearly you are having a hard time -- but hurling insults and > calling people clueless will not get you any help, or sympathy for > that matter. PowerShell, His example is FLAWED is ANY language, I should have x-posted it to the C++ group, at least they'd confirm it's flawed. It's not RichS's fault, he copied it from Microsoft own clueless website. -- Gerry Hickman (London UK) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| create Ad user on local machine | PowerShell | |||
| How to view remote certificates installed on remote machine? | PowerShell | |||
| Exch 2003, create Mailbox from Vista machine? | PowerShell | |||
| checked for logged on user on remote machine + remote reboot | PowerShell | |||
| Can't create a new file or folder with in a shared folder on a Windows XP machine. Basic Vista networking questions | Vista installation & setup | |||