PowerShell V6 SmbShare commands returning error ... is not recognized as the name of a cmdlet, function, script file, or operable program - smb

I'm new to PowerShell, so this may be a basic oversight.
On windows 10 pro (for development) and Windows Server 2016 (target environment) I have installed the latest released version of PowerShell.
(Get-Host).Version gives Major 6, Minor 1, Build 0, Revision -1.
My first mistake? as a version of PowerShell is already installed by default?
The process I am trying to automate is to share a backup cartridge drive from host physical machines, and access it as a network share for the VMs (Hyper-V) to backup to. In development I'm just using a USB attached drive, but errors are the same in both environments.
I keep getting errors in any of the SMBShare commands :
Get-SmbShare, Remove-SmbShare, New-SMBShare.
The errors are of the format:
"The term 'Get-SmbShare' is not recognized as the name of a cmdlet,
function, script file, or operable program"
I am running Powershell as administrator, and getting the same errors when typing directly, or from running a script.
Is there something I need to add/import to use SMBShare commands ?

PowerShell has fractured; everything up to v5.1 was Windows only, then v6 was made cross-platform by moving it to a new foundation, and that lost a lot of compatibility.
Your easiest way forward is to use PowerShell 5.1, unless you need v6 for some specific feature. Or to use 6 to launch 5.1 and run a script, the same way you might launch Python or VBScript engines to run a script.
But if you are staying with 6, then there is another option - Microsoft have released a WindowsCompatibility Module - still an early release candidate, so not heavily tested. This brings a way to run Windows modules inside PS v6 (only on Windows, not cross platform).
You would need to install it, with this as an administrator:
Install-Module WindowsCompatibility
Then you can:
Import-Module WindowsCompatibility
Import-WinModule SmbShare
Get-SmbShare

Related

How to enter Windows-Subsystem-for-Linux (ubuntu) from PowerShell at the current PowerShell working dir

When running the command bash or ubuntu in PowerShell, the Windows-Subsystem-for-Linux is entered, however, the current working dir for PowerShell is not carried across to BASH. Is there a way to implement this functionality?
From your Windows Powershell or Powershell Core window, type bash (or wsl); for example:
Now, later versions of Windows include WSL.exe, which replaces bash.exe. The behavior of both executable is the same on my system. The official documentation for wsl.exe states:
You can read that documentation here. Net-net,
I'm running Windows 10 Build-17763. If you aren't experiencing the same behavior I am, you might be running an older version of WSL. You can determine the version of WSL from your build number.

Compiled Visual Basic Application gets Runtime Error 52 in Windows 8

The application that I compiled via Visual Basic 6 can run on my Windows XP computer. But when I execute the same executable on my other computer that runs Windows 8, I always get Runtime Error 52-Bad File name or number as soon as I launch it. I can't run the program even if there is no "Shell command" in that program which leads to a "Bad file name" error.
I used "Package and Deployment wizard" for the packaging process.
And also I registered the needed DLL's on the Windows 8 PC manually via the regsvr32 command line utility.
I also cleaned the whole registry via a registry cleaner (Wise Registry Cleaner). I used compatibility mode for Windows XP but nothing solved the problem.
Additional informations:
XP Version - SP 2
Windows 8 Version-8.1
VB - VB 6.0
Assuming that your code is
If Dir("C:/file.txt") = "" Then...
Change it to a backslash ("\")
After some research I found the answer for the problem. That was not a problem in the coding; it was ALL about windows 8 compatibility.
Go to the “Compatibility” tab of the properties window of the file and select “Windows XP SP2” under the “Compatibility mode”. That’s all
Windows 8 no longer allows you to write programmatically in the root of drive C:\ (and in many others 'system' folders like Program Files, Windows, System32, ...).
Try to use a sub-folder.

How to enable bash commands in Windows CMD?

I've two Windows machines and both have bash installed. However, they differ in the way bash starts up:
Machine 1:
Typing "bash" starts the bash. Then I can type commands like ls.
Machine 2:
It seems like it starts bash and directly runs ls in it, by only typing "ls". After that it switches back to CMD automatically, like this:
Does anyone know which setting enables the behavior of machine 2? Everything looks the same for me. It's a nice feature and I want to enable it on machine 1 as well.
Bash on Ubuntu on Windows executables (binaries) cannot run from Windows applications such as cmd.exe or PowerShell.exe - Windows doesn't even see them as executable.
The likeliest explanation is that you've installed a separate Unix emulation environment such as GnuWin, which comes with native Windows binaries.
To see the location of your - by definition Windows-native - ls executable, run where ls, which will probably tell you what product it came with, such as
C:\Program Files (x86)\GnuWin32\bin\ls.EXE.
Note that the Ubuntu on Windows binaries are stored in a user-specific manner in
%LOCALAPPDATA%\lxss\rootfs\bin, but that is a moot point, given that you cannot invoke them from Windows.
In Windows 10, there is a built-in Linux subsystem (one of the greatest features of Windows 10). It gives you almost a complete Linux shell for various distributions, and you can almost do anything with it (user mode).
I bet it is installed on your first computer, and you are using that subsystem. In the latest version of this subsystem, you can run both Linux executables and Windows exe files.

jenkins: windows xp, windows 7 slave cannot execute commands

I have a Arch Linux master that drive 2 arch linux slaves, 1 windows xp slave and 1 windows 7 slave. Linux part is all ok, I managed in some way to start windows slave using automatic execution and slave.jar. I have an external program that need to be executed and it's installed on c:\program files (x86) on windows7 and on c:\programs on windows xp.
I went on path variables and inserted the two path on the two systems, but when I try to run jenkins build it says "command not found"
I tryed to place 2 bat files in c:\ poining to the right place, based on every system, but it says c:\build.bat command not found. I can see the file in the right place...
How do you manage executables placed in different places on different computers?
there's a better way to run the program?
I can change everything about this installation, the only thing I need it to find a way for starting that program.
thank you for your help.
Have you verified that the changes you made to the system path were actually saved? Make sure both of the slaves have been rebooted and then test this via a standard command line window.
If the program you're trying to execute is actually on the path, you could also look at the Envfile Plugin.
After adding new paths to your environment variable PATH you need to restart jenkins slave service in order to allow it to use these new PATHs.
I solved the problem changing the way jenkins start the job on the slave. I used "Execute shell" and some program are executed. I changed "Execute shell" with "Execute windows batch command" and everything works fine.

Node.js - tutorials on getting it to work with Cygwin on a Vista machine

All,
Am trying to get Node.js to work on Vista machine.
I installed Cygwin (as per the Github instructions) which appears to have been installed correctly. However, none of the commands are executing.
Are there any tutorials for the stages after the Cygwin installation?
PROBLEM: When any command is executed, I get 'Bash: command not found' error.
Not even command like 'c:\cygwin\bin' is executing.
When I type 'user' in cygwin command prompt, I get 'ntvdm has encountered an system error. Parameter incorrect'.
I thought the above error may be due to the firewall, disabling the firewall did not have any effect, running the program with admin rights also did not change the results...
Am confused and would love to get some guidance on what steps to go with next on getting Node.js up and running on a Windows Vista machine.
Many thanks,
UPDATE1:
We managed to make a bit more progress. It appears that we had not installed all the relevant files related to Cygwin. Upon re-download and reinstalled, it ran well, however, we have driven into another error. Error we get:
How to compile/install node.js(could not configure a cxx compiler!) (Ubuntu).
We followed the instructions as per the above thread (3rd post from top for Windows machines), however, we are still stuck at the same error.
Any guidance please?
Have you tried just using the Windows self contained binaries? http://node-js.prcn.co.cc/ This way you actually don't need to bother with Cygwin.
At first, i tried it your way too, using Cygwin. After smashing my head for the 10th time against a wall i just stopped trying and found a much cleaner solution.
I'm using VirtualBox running a Debain guest system to locally develop on my Windows 7 machine. Using VirtualBox, you can easily set up shared folders or port forwarding for node apps between your Windows machine and your Debian guest system.
Since you are using a plain Linux-system, all the compiling-pain is blown away.
If you plan to run node.js in production on a windows system: don't. I hardly believe node.js will be ever stable enough on windows-based systems using MINGW/Cygwin...
People seem to run into problems with Cygwin because they think that they are using a Windows machine.
If you install Cygwin, and open a bash shell prompt using the Cygwin icon, you are now in a UNIX environment and everything works the same as it would on UNIX. That includes building node.js.
I think you added some info to the question and I can see your problem. Yes, normally on Cygwin it has been possible to build node.js just as you would on any UNIX system, but that is no longer possible on Windows 7. Before running ./configure you have to:
Close all cygwin apps.
Double-click on C:\Cygwin\bin\ash.exe
Run ./rebaseall and when it completes, run ./perlrebase.
exit from the ash shell window.
At this point Cygwin will be back to normal and you can ./configure and make install.

Resources