Skip to content

Commit

Permalink
fix: supports WinPS
Browse files Browse the repository at this point in the history
  • Loading branch information
amkhrjee committed Jan 5, 2023
1 parent 778702b commit c4edf5f
Showing 1 changed file with 75 additions and 10 deletions.
85 changes: 75 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,94 @@
## What does `ocwd` do?
`ocwd` is a command line utility that downloads resources from any [MIT OCW](https://ocw.mit.edu/) course to any storage path provided by you. The resources are available under the creative commons license and MIT reserves all rights to the content. This tool simply scrapes the OCW website for resources and offers a simple and easy way for downloading any course resource for offline use.
## Installation Guide
> This script only works on 🪟Windows.
> This script only works on 🪟Windows (🐧Linux + 🍎MacOS support coming soon!)
`ocwd` requires Microsoft's cross-platform [PowerShell-Core](https://github.com/PowerShell/PowerShell/), if you don't have it already installed, read their [installation guide](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3).
`ocwd` works with both Windows PowerShell and the cross-platform PowerShell-Core.

This tool works best with PowerShell-Core `v7.x.x`. That means, it is recommended to update your PS installation to the latest available version.
All recent versions of Windows 10 & 11 already come with Windows PowerShell installed (search for `PowerShell` using Windows Search to find out whether you have it or not). However, you can also follow the installation guides provided here in case you don't have PowerShell installed.

If you are installing a script for the first time, the following instructions will help you get started, otherwise you can skip ahead to the installation script.
If you have PowerShell installed, skip to the `ocwd` installation script.

With the latest version available, we need to set the `ExecutionPolicy` to `RemoteSigned` as the default one is unsuitable for running user downloaded script.
Next, we need to set [PSGallery](https://www.powershellgallery.com/packages/ocwd) as a trusted source for our scripts, as `ocwd` is hosted at PSGallery repository.
<details>
<summary>
PowerShell Installation Guide
</summary>
PowerShell comes in two flavours - PowerShell Windows and PowerShell-Core. You are recommened to download PS-Core, as it is the one in active development by Microsoft and thus have the latest features. `ocwd` downloads work faster with PS-Core (thanks to multi-threading!)

<br>

### PowerShell Core Installation Guide
You can read the official installtion guide here.

PowerShell Core is a cross-platform version of PowerShell that is open-source and available on Windows, macOS, and Linux. Here is a guide to install PowerShell Core on your system:

1. First, visit the following link to download the latest version of PowerShell Core: https://github.com/powershell/powershell/releases

2. Select the appropriate download link for your system. For example, if you are running Windows, select the MSI installer link. If you are running macOS or Linux, select the appropriate package for your system.

3. Once the download is complete, open the installer file and follow the prompts to install PowerShell Core on your system.

4. Once the installation is complete, you can launch PowerShell Core by opening a terminal window and typing `pwsh`.

To verify that PowerShell Core has been installed correctly, you can run the following command:

```ps1
$PSVersionTable
```
This should display information about the version of PowerShell Core that you have installed.

That's it! You have now installed PowerShell Core on your system. You can start using PowerShell Core by typing commands into the terminal window.

### Windows PowerShell Installation Guide

Windows PowerShell is a command-line shell and scripting language that is included with Windows by default. Here is a guide to install Windows PowerShell:

1. Check if Windows PowerShell is already installed on your system. To do this, open the Start menu and search for "PowerShell". If PowerShell is installed, you should see it listed in the search results.

2. If Windows PowerShell is not installed on your system, you can install it by following these steps:

#### On Windows 10/11:

- Go to the Start menu and select "Settings".
- Select "Apps" from the settings menu.
- Click on "Apps & features" from the left menu.
- Click on the "Manage optional features" button.
- Click on the "Add a feature" button.
- Scroll down the list of features and select "Windows PowerShell".
- Click the "Install" button to begin the installation process.

#### On Windows 7:

- Go to the following link to download the Windows Management Framework (WMF) installer: https://www.microsoft.com/en-us/download/details.aspx?id=54616
- Once the download is complete, open the installer file and follow the prompts to install WMF on your system. This will install Windows PowerShell on your system.

3. Once the installation is complete, you can launch Windows PowerShell by opening the Start menu and searching for "PowerShell".

4. To verify that Windows PowerShell has been installed correctly, you can run the following command:
```ps1
$PSVersionTable
```

This should display information about the version of Windows PowerShell that you have installed.

That's it! You have now installed Windows PowerShell on your system. You can start using Windows PowerShell by typing commands into the terminal window.
</details>


`ocwd` is currently available via Microsoft's [PSGallery](https://www.powershellgallery.com/packages/ocwd/1.1.1). If you have installed external scriipts before, you can skip to the installation script, otherwise, open PowerShell in Administrator Mode and paste the following:

To do this, start PowerShell 7 in *Administartor Mode* and type/paste the following:
```ps1
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
```

Finally, paste the following in your PowerShell terminal to install `ocwd` to your system.
This will install `ocwd` to your system:
```ps1
Install-Script -Name ocwd
```

After the installation is over, you are suggested to close and reopen your terminal for reloaing the shell.
## Demo
<img src="https://i.imgur.com/ODutHXm.gif" />
<!-- <img src="https://i.imgur.com/ODutHXm.gif" /> -->

![demo image](https://i.imgur.com/1yPPAng.png)

Expand Down

0 comments on commit c4edf5f

Please sign in to comment.