powershell : has anyone tried to install powershell on windows 2000 server? - windows

Has anyone tried installing powershell on a Windows 2000 server? I realize its not supposed to be installed on windows 2000 server and therefore not supported; however the vbscript that runs on it takes 3.5 days to complete which powershell could probably finish in lesser time. Nevertheless, I noticed it just requires .NET 2.0 to run.
thanks in advance.

If you have administrator access to the Windows 2000 server in question, you could run PowerShell on a supported machine in the same domain and use set-location to change your working directory to the remote server
cd \\remoteserver\<drive>$\path\to\folder\you\want\to\start\in
You could then run whatever PowerShell script you want on the remote directory. If the folder you are starting in is shared, it is even simpler (you won't need to access the admin share). Or you could map a drive on your machine with PowerShell that links to the target directory.
This might be a smoother option than forcing an install on a non-supported machine.

Yes. This works. Instead of installing Powershell on the server, just remotely talk to it like :-
Set-Location "\\MyServer\D$\wwwportal\MyChangedFileFolder\"
Get-ChildItem -filter *.txt -Recurse

Related

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

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

Run appx file in current Windows 10 device using the PowerShell cmdlets

I have an appx file which was generated elsewhere and I would like to test it in my Windows 10 machine.
The appx file is already available to me and I can deploy it to other devices using the WinAppDeployCmd, which works for the XBox One. This works perfectly with the following command:
WinAppDeployCmd install -file "!MY_FILE!" -ip "!DEVICE_IP!" -pin "!DEVICE_PIN!"
My question is, is there a similar command to simply run my .appx in the windows machine where it currently is? Is there perhaps even a way to use the WinAppDeployCmd to install it in the current machine?
I don't know about cmd, but in PowerShell you can use
Add-AppxPackage -Path C:\Users\User\MyApp.appx
If the package is unsigned, you will need to enable developer mode in Windows 10 before it can be installed.
Open Settings.
Click on Update & security
Click on For developers.
Under “Use developer features”, enable Developer mode.
More information on Add-AppxPackage: https://technet.microsoft.com/en-us/library/hh856048.aspx
Update: Regarding using WinAppDeployCmd for this see: Can I Use WinAppDeployCmd install, update on pc itself

How to get path to Linux installation from within WSL in Fall Creators Update

Before the recent update WSL root filesystem was always in C:\Users\%username%\AppData\Local\lxss, but now when Linux is installed from the App Store it can be different for each installation. For example for Ubuntu on my machine it is C:\Users\%username%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
Is there a way to detect this path from within current WSL session?
As noted by other users, nowadays you can install multiple Linux distributions and each distribution have their own filesystem located in a different folder. The location of each filesystem can be obtained from the Windows Registry.
You can run regedit and look for the information. The data is located under
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss
In addition, you can start a PowerShell window and execute the following command to determine information of all the installed Linux distributions.
(Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse)
To obtain the location of the filesystems, you can run
(Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName,BasePath
In PowerShell:
> echo ($env:LOCALAPPDATA + '\Packages\' + ($(get-appxpackage).PackageFamilyName|findstr UbuntuonWindows))
C:\Users\Reker\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
You can run above command in bash.exe on Windows 14393 or above by interop with windows cmd.exe or powershell.exe

powershell won't start without CD in drive

I am using Windows 7 and have upgraded to Windows Management Framework 3.0, which includes PowerShell 3. Within the past week or so, I have started getting an error upon starting PowerShell that prevents it from starting until there is a CD in my computer's drive (any CD will do). The only fix I have found so far—and this is only a temporary fix—is to completely uninstall and reinstall the Management Framework. This works until I use the CD drive for something, then PowerShell starts acting up again. The error dialog reads: There is no disk in the drive. Please insert a disk into drive D:.
Does anybody have any suggestions for what might be going on here? I see two possible problems related to configuration settings, but still need guidance about what/where to check and verify:
PowerShell is configured somewhere to check certain drives on startup, and isn't responding well to an empty CD drive
PowerShell is actually trying to open to some path on D:\. I'm pretty sure this is not the problem, since it opens to my %USERPROFILE% when there is a CD in the drive, but of course I could be missing something
Of course, I'm sure there are plenty of other possibilities I haven't considered
Any thoughts on possible fixes? I'd like not to have to uninstall and reinstall the Management Framework every time I use my CD drive!
EDIT: Additional details below copied from my responses to various comments
I can recreate the error by launching PowerShell in multiple ways. Shortcut is one. Starting it from a Command Prompt (cmd.exe) is another. Even trying to call a PowerShell script from a Command Prompt using something like PowerShell -ExecutionPolicy RemoteSigned -File script.ps1 produces the error, and so does PowerShell /?.
I don't see anything pointing to D:\ in $env:PATH and $env:HOMEDRIVE is not set to D:. %windir% is set to C:\Windows, %SystemDrive% is set to C:, and %SystemRoot% is set to C:\Windows.
Re-assigning the CD drive to a different letter resolves the problem, but this isn't a solution because it addresses the symptom and not the underlying cause (whatever that is).
When everything else fails, I can still start PowerShell from Cygwin
Process Monitor (linked below) is showing an attempt to read a non-existant registry entry HKCU\Software\Classes\Local Settings\MuiCache\5E6\52C64B7E\#D:\Windows\system32\AccessibilityCpl.dll,-10. Whatever mechanism is causing that bad read is likely also causing the error dialog. Something must be programmatically changing the system drive within PowerShell itself.
Further thoughts and suggestions are appreciated.
When Powershell first launches, it checks designated folders to import modules. I would take a good look at these. The default var is $env:PSModulePath and acts much like the standard $env:Path var. I would review that path and see if there are any references to the D: drive there.
MSDN - Windows PowerShell Modules
Are you installing .net from the DVD drive? Maybe downloading a fresh copy from MS would clear this up. MS .Net Framework 3.0 is very old, it is actualy designated for Server 2003 or WinXP. Is there a reason you are using it instead of 3.5, 4 or 4.5.1?

How to make tasklist.exe run on windows 2000

Can someone please tell me how to make tasklist.exe file run on Windows 2000. I downloaded the file from net & placed under the system32 folder. However when I tried to execute the file it prompted me a message "ERROR:the target system must be running Windows XP or above"
So can someone please tell me how to run this on windows 2000? I badly need this, as I am doing a batch script to find out the foreground processes running in my windows 2000 machine.
Appreciate your help.
I looked but couldn't find a version for Windows 2000. But I did find this article on using an alternative program.
The original tasklist.exe will not work in stock Windows 2000 because it's looking for APIs which don't exist there. You can use a modified version created blackwingcat:
http://blog.livedoor.jp/blackwingcat/archives/1372175.html
Just download and unpack taskcmds.cab.

Resources