I'm using Windows 8.1, and I can't use some commands in PowerShell.
For example, commands about AD User (Get-ADUser, New-ADUser), or commands about certain Windows features (Get-WindoswFeature, Enable-WindoswFeature).
A lot of people use above commands, but I can't use them.
I don't know why it is. Please help me
The PowerShell modules for those commands are not installed on client operating systems by default. You have to install the Remote Server Administration Tools for your specific client OS to get the modules.
Related
I am trying to run a windows batch command from CentOS 6. I would like to know the best way to achieve this. I explored PsExec and WinExe utilities in unix to connect to windows machine and run the required commands.
I am trying this on a windows VM which is within company network, hence kindly highlight any specific network issues that I may have to check for the setup to run.
Any pointers would help.
Have you seen the examples from the PowerShell for Linux GitHub pages, as the working examples seem to cover this off nicely?
https://github.com/PowerShell/PowerShell/tree/master/demos/SSHRemoting
It will require SSH installed onto your Windows server, but otherwise seems to tick all of your boxes.
I wonder what guest OS are compatible to the invoke-VMScript cmdlet. The reason I'm asking: I plan to include VMWare in my (automated) test environment. What I read so far:
Windows Server 2008
Windows Server 2012
A Fedora-Version
I would like to know, what windows and linux guest you have experience with and (if appliable) what languages are invokeable. E.g. CMD at windows, or maybe Bash or Powershell at Linux.
According to the documentation powershell bat(cmd) and bash are all supported, I don't have a linux machine handy to confirm but based on this link it looks like you can run powershell on Linux VM's as long as .Net and Powershell have been installed and the machine has been rebooted since this install. Beyond that depending on the VM config you can use any of those methods to create and launch scripts that target just about any language by building them as strings inside of the script that is delivered, writing them to a temp file and then launching the correct interpreter and calling the newly created file. note that there seem to be a bunch of edge-cases here so you may want to review the requirements here
I am distributing an installer and it will open and run a PowerShell script. The installer will be used by people who have Windows XP and up.
Am I guaranteed that this script will run/execute on all these versions of Windows? I'm looking for the similar Cross-Windows-Platform interoperability that Batch files provide.
I've heard of the error: "File cannot be loaded because the execution of scripts is disabled on this system" what can I do in this scenario? If a user has disabled scripts does that mean I will need to use a different language(maybe just Batch)?
The error you're quoting is due to the default execution policy of PowerShell when it's installed. The message indicates that PowerShell is installed,but by default it's very restricted about what scripts may run for security purposes.
See this article for more on the subject.
If you're going to use PowerShell in your installer, make it part of the system requirements for your software. I can't find anything that definitively says you can redistribute PowerShell with your application, but it's worth asking Microsoft about it.
PowerShell isn't "guaranteed" to be on any desktop OS older than Win7, but it is distributed via Microsoft Update and there's no compelling reason for users to not have it installed.
If you manage this environment, then make sure that powershell is installed on the XP workstations before deploying the script. There is also the option of configuring group policy for powershell to enable script execution and what type of scripts to allow, but that's outside the scope of this question.
If you don't go the group policy route, and instead want to just run the script directly, then in your installer, call powershell.exe directly and pass in the following parameters:
powershell.exe -executionpolicy bypass -file \\path\to\script
The script path doesn't have to be a unc path if it's local, that was just an example.
No, PowerShell scripts are not guaranteed to run on Windows XP or Windows Server 2003. Although PowerShell is available for these platforms, it's not installed by default.
No, PowerShell scripts may not work, because the PowerShell isn't pre-installed on Win XP/2003.
It is included in the Management Framework for XP/2003.
For me, I suggest to use the .bat instead.
is it possible to execute a command (ex: launching a .bat file located on the remote machine) on a Windows Remote Machine, using a UNIX or Linux Machine ?
Is there something like a scp/ssh mechanism or at least a way to connect to a Windows Machine passing through the network ?
Thanks for your help.
By default, recent Windows versions only support the Remote Desktop protocol. As far as I know, client versions only allow a single user, while server versions with installed Terminal Services allow for multiple simultaneous users.
Windows Server versions also support the Telnet protocol, but the server is disabled by default - it may not even be installed. Therefore you will have to enable it manually. Do you really want to use Telnet of all things, though? Just the security concerns are enough to make it mostly useless.
There is also a version of OpenSSH for Windows, that uses the Cygwin DLL. I have not tried it, but using an SSH implementation from the Unix world does have its appeal (and probably a few disadvantages). See also this.
EDIT:
Recent Windows versions also support the Windows Remote Management system, which allows you to launch an interactive session throuh a bit of trickery.
You may want to try Vandyke VShell.
When I was a Linux admin I could do anything from the SSH command line. Now, as a Windows admin, I have to deal with the Windows Remote Desktop graphical interface, which I found to be inefective (slow) and hard to automate tasks in it.
a) Can I connect to a Windows Server through SSH or any encrypted connection with command line interface?
b) If yes can I do ANY administrative task?
Examples:
create a new virtual folder in IIS
setup firewall ports
restart services
change user policies
start desktop applications
I know about the existence of Windows PowerShell 2.0 Remoting, but I don't know if it fullfills all conditions above
My conclusion so far: from Windows PowerShell can do MOST but not ALL administrative tasks. And I still don't know if Windows PowerShell 2.0 Remoting uses an encrypted connection.
PowerShell is what you're looking for. It is primarily targetted at system administration (although it's fanastic as a programmer's shell, too).
PowerShell v2 remoting is based on Windows Remote Management. See http://msdn.microsoft.com/en-us/library/aa384426(VS.85).aspx. It includes facilities for ecryption and authentication, as you'd expect.
PowerShell includes cmdlets that let you do a lot of everyday tasks. Microsoft server applications (IIS, Exchange, etc.) either have or are building PowerShell cmdlets to administer them. PowerShell's WMI support is excellent, giving you a lot of machine administration power. PowerShell can talk to .NET directly, which lets you go further than built-in facilities when needed. And writing C# for PowerShell to call works out cleanly, too.
You asked for a command line interface, but don't think that you're restricted to the ancient and crufty Windows Console subsystem. PowerShell v2 includes a new GUI interactive shell / script editor, with colorization and debugging. It's sweet.
You can also try http://sshwindows.sourceforge.net/
I don't have personal experience with it but it looks promising.
Did you consider Google? (looks like you edited your question. You now no longer ask if the example tasks can be achieved using PowerShell)
Powershell snap-in for IIS 7
Restart-Service
Group policies
etc...
Sorry for not answering your question. I was in a similar situation.
I gave up to do all tasks on the windows shell
Instead I do use the shell for some tasks, but I am also using rdesktop (through ssh) and I put icons for the most important gui admin tools on the windows quicklaunch.
I gave up making windows feel like unix because it never will.
alternatively try to download and install eurysco to use the following features that is based on another logic...
1.create a new virtual folder in IIS (from eurysco commandline to launch vbs or powershell script)
2.setup firewall ports (from eurysco commandline to launch netsh.exe advfirewall)
3.restart services (from eurysco service control)
4.change user policies (from eurysco system registry or commandline to launch powershell script)
5.start desktop applications (from eurysco commandline to launch powershell script)
http://www.eurysco.com/features