powershell - bat file to install .net 3.5 framework for win server 2012 -


i want make bat file install .net framework 3.5 on windows server 2012. tried no success:

cd /d %userprofile%  c:\windows\system32\windowspowershell\v1.0\powershell.exe  import-module servermanager  powershell -importsystemmodules add-windowsfeature net-framework-features 

seems after entering powershell console last 2 commands not executed.

does have idea why getting stuck?

or have other bat file how automate install of .net 3.5 in windows server 2012?

after more trying made bat working following command when run manually.

call c:\windows\system32\windowspowershell\v1.0\powershell.exe -importsystemmodules add-windowsfeature net-framework-features 

but when try run dotnetinstaller same bat not working anymore

 <component command="cmd.exe /k &quot;#apppath\install.net3.5.bat&quot;" command_silent="" command_basic="" uninstall_command="" uninstall_command_silent="" uninstall_command_basic="" returncodes_success="" returncodes_reboot="" disable_wow64_fs_redirection="false" id=".net 3.5 sp1 win8server" display_name=".net 3.5 sp1" uninstall_display_name="" os_filter="" os_filter_min="winserver2008r2" os_filter_max="" os_filter_lcid="" type="cmd" installcompletemessage="" uninstallcompletemessage="" mustreboot="false" reboot_required="" must_reboot_required="false" failed_exec_command_continue="" allow_continue_on_error="true" default_continue_on_error="false" required_install="true" required_uninstall="true" selected_install="true" selected_uninstall="true" note="" processor_architecture_filter="" status_installed="" status_notinstalled="" supports_install="true" supports_uninstall="false" show_progress_dialog="true" show_cab_dialog="true">  <installedcheck path="software\microsoft\net framework setup\ndp\v3.5" fieldname="install" fieldvalue="1" defaultvalue="false" fieldtype="reg_dword" comparison="match" rootkey="hkey_local_machine" wowoption="none" type="check_registry_value" description="installed check" />       <installedcheck path="software\microsoft\net framework setup\ndp\v3.5" fieldname="sp" fieldvalue="1" defaultvalue="false" fieldtype="reg_dword" comparison="match" rootkey="hkey_local_machine" wowoption="none" type="check_registry_value" description="installed check" />     </component>   

i error idea why?

the term 'add-windowsfeature' not recognized name of cmdlet, functi on, script file, or operable program. check spelling of name, or if p ath included, verify path correct , try again. @ line:1 char:19 + add-windowsfeature <<<< -name net-framework-features + categoryinfo : objectnotfound: (add-windowsfeature:string) [], commandnotfoundexception + fullyqualifiederrorid : commandnotfoundexception

two options:

1) use script file , file parameter.

############# ## script.ps1 import-module servermanager add-windowsfeature net-framework-features 

then execute:

powershell -file c:\script.ps1 

2) use command parameter:

powershell -command "import-module servermanager; add-windowsfeature net-framework-features" 

in case, try avoid -importsystemmodules switch (deprecated in v3), it's overkill. load system modules when need servermanager module. , if working in v3, import-module command redundant well. see module autp-loading feature.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -