get-module not listing out failoverclusters module when CreateProcess() or system() called
-
Thursday, August 13, 2009 4:16 AMHi,
I need to use FailoverClsuters module realted cmdlet, so I installed FailoverCluster feature(I logged in through domain\admin account) on my machine and then verified get-module -list the module and import-module FailoverClusters also success through PoweShell window.
>get-module
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest ADRMS {}
Manifest AppLocker {}
Manifest BestPractices {}
Manifest BitsTransfer {}
Manifest FailoverClusters {}
Manifest PSDiagnostics {Enable-PSTrace,...}
Manifest ServerManager {}
Manifest TroubleshootingPack {}
Strangely, when I tried calling the same thing in system() /CreateProcess () it list only the below modules(FailoverClusters module is missing):
// system("powershell.exe get-module")
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest BitsTransfer {}
Manifest PSDiagnostics {}
Manifest TroubleshootingPack {}
I'm having the following execution policy set on my machine:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
Any reasons why I'm not able to get/load the FailoverClusters module?
Thanks in advance,
Arjun.R
Before software can be reusable; it first has to be usable.- Edited by Arjun R Thursday, August 13, 2009 4:52 AM
All Replies
-
Thursday, August 13, 2009 11:38 AMModeratorThese are features available with R2, so you should really post this here:
http://social.technet.microsoft.com/Forums/en-US/windowsserver2008r2management/threads
This is interesting, can you provide more sample code? If not, I can manage on my own, but it will take me a few days (likely next week) before I can get to it. -
Monday, August 17, 2009 3:54 AM
Hi,
Here is the code what I used:
////////////////////////////////////////////////////////////////////////////////////
int _tmain(int argc, _TCHAR* argv[]) { STARTUPINFO si; PROCESS_INFORMATION pi; LPTSTR szCmdline=_tcsdup(TEXT("powershell.exe get-module -listavailable")); int iRet = 0; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess( NULL, // No module name (use command line) szCmdline, // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi ) // Pointer to PROCESS_INFORMATION structure ) { printf( "CreateProcess failed (%d).\n", GetLastError() ); return 0; } // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); return 0; }
////////////////////////////////////////////////////////////////////////////////////
Thanks,
Arjun.R
Before software can be reusable; it first has to be usable. -
Monday, August 17, 2009 10:02 AMModerator
Hi,
I suggest that you initial a new post in the MSDN form to get further support there. They are the best resource for development related problems.
For your convenience, I have list the link as followed.
MSDN Forum
http://forums.microsoft.com/MSDN/default.aspx?SiteID=1Thanks.
This posting is provided "AS IS" with no warranties, and confers no rights. -
Tuesday, August 18, 2009 1:38 AMModeratorI don't have any skills at all in C... Do you get an error returned if you try to manually load one of the modules that isn't listed?
I'll try this from C# tomorrow to compare. -
Tuesday, August 18, 2009 6:20 AMI got below error when: system("powershell.exe import-module failoverclusters") is called:
---------------------------------------------------------------------------
Import-Module : The specified module 'failoverclusters' was not loaded because
no valid module file was found in any module directory.
At line:1 char:14
+ import-module <<<< failoverclusters
+ CategoryInfo : ResourceUnavailable: (failoverclusters:String) [
Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
ands.ImportModuleCommand
--------------------------------------------------------------------------- -
Tuesday, August 18, 2009 1:12 PMModerator
Hi,
I need to use FailoverClsuters module realted cmdlet, so I installed FailoverCluster feature(I logged in through domain\admin account) on my machine and then verified get-module -list the module and import-module FailoverClusters also success through PoweShell window.
>get-module
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest ADRMS {}
Manifest AppLocker {}
Manifest BestPractices {}
Manifest BitsTransfer {}
Manifest FailoverClusters {}
Manifest PSDiagnostics {Enable-PSTrace,...}
Manifest ServerManager {}
Manifest TroubleshootingPack {}
Strangely, when I tried calling the same thing in system() /CreateProcess () it list only the below modules(FailoverClusters module is missing):
// system("powershell.exe get-module")
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest BitsTransfer {}
Manifest PSDiagnostics {}
Manifest TroubleshootingPack {}
I'm having the following execution policy set on my machine:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
Any reasons why I'm not able to get/load the FailoverClusters module?
Thanks in advance,
Arjun.R
Before software can be reusable; it first has to be usable.
Was that just a typo above where you mention you tried "//system ("powershell get-module")"? You realize there you are missing "-list"... -
Monday, August 24, 2009 6:24 AMNo! I used all ways it was(powershell.exe get-module / powershell.exe get-module -list ) not listing/loading all modules.
-
Tuesday, June 08, 2010 6:26 PM
I am not sure if this has been answered. But still i would share my thoughts for others.
First, to answer your question
Any reasons why I'm not able to get/load the FailoverClusters module?
Your application is an X86 application and in that case when you launch powershell.exe it launches x86 version of powershell. FailoverClusters module is not availabel for x86 arc and thats the reason you do not see the FailoverClusters module. If you convert you application to buid for x64 it will work.
Well I am not sure what you want to do , but i do want to point out that imported modules are available per session and for every commandlet that you want to call, you will have to first import the module and then run the cmdlet. I would suggest writing you application in managed language where you can actually write a powershell hosting application using PowerShell SDK.
- Marked As Answer by Marco ShawModerator Tuesday, June 08, 2010 10:52 PM

