Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, August 13, 2009 4:16 AM
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.
All replies (8)
Tuesday, June 8, 2010 6:26 PM âś…Answered
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.
Thursday, August 13, 2009 11:38 AM
These 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 AM
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=1
Thanks.
This posting is provided "AS IS" with no warranties, and confers no rights.
Tuesday, August 18, 2009 1:38 AM
I 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 AM
I 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 PM
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 RemoteSignedAny 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 AM
No! I used all ways it was(powershell.exe get-module / powershell.exe get-module -list ) not listing/loading all modules.