Windows Server 2019 - Scripting and Sharing
Windows PowerShell
Microsoft Windows PowerShell can be accessed directly from the Windows Admin Center. Connect to your Windows Server via Admin Center and find PowerShell under Tools. Log in with your account.
Running PowerShell Commands
Execute PowerShell commands directly from the web interface. For example, create a new user with New-LocalUser -Name Peter
.
Search for Local user & groups under tools in Admin Center and open user management in a new tab to see the created user.
Working with the filesystem follows similar steps. Use commands like Get-ChildItem
, New-Item
, Copy-Item
, and Remove-Item
.
Get-ChildItem -Path C:\
New-Item -Path 'C:\scripts' -ItemType Directory
New-Item -Path 'C:\scripts\test' -ItemType Directory
New-Item -Path 'C:\scripts\test\helloworld.ps1' -ItemType File
Copy-Item -Path 'C:\scripts\test\helloworld.ps1' -Destination 'C:\scripts\hello.ps1'
Remove-Item -Path 'C:\scripts\test\helloworld.ps1'
Run commands to view processes and services:
Get-Process
Get-Service
PowerShell Scripting
Run local shell scripts through PowerShell. Store scripts with the .ps1 extension. Here’s an example script:
echo 'Hello World'
sleep 10
Save as helloworld.ps1, navigate to the directory, and run the script as .\helloworld.ps1
.
Creating a Samba Share
Enable Remote Desktop on the server. Add a Desktop on your host machine in Remote Desktop. Connect to the remote server using the server name or IP address.
Right-click the directory to share, choose Properties, Sharing, Advanced Sharing. Name the share and set Permissions.
Discover the share from your host machine and connect using specified user login.