100% found this document useful (2 votes)
31 views1 page

Part III

This document discusses how to create, share, and remove a network folder using PowerShell commands. It explains how to use variables to store folder paths, share names, and other values. The steps shown create a folder called "Temp" on the C drive, share it with the name "Temporary", then remove the share. Key commands include New-Item to create the folder, Get-WmiObject to view current shares, and $objWMI.create() and .delete() to share and remove the shared folder.

Uploaded by

daimon81032648
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
31 views1 page

Part III

This document discusses how to create, share, and remove a network folder using PowerShell commands. It explains how to use variables to store folder paths, share names, and other values. The steps shown create a folder called "Temp" on the C drive, share it with the name "Temporary", then remove the share. Key commands include New-Item to create the folder, Get-WmiObject to view current shares, and $objWMI.create() and .delete() to share and remove the shared folder.

Uploaded by

daimon81032648
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Part III: Network File Management

Introduction: In this exercise you will create a folder share it out to the network and the remove
the shared drive from the network, but first I have to explain variables in some detail so that you sill have
an understanding of what you typing in and so that in the future you can set your own variables.
When ever you add a “$” in front of a world or object you are telling Powershell to remember this
value/ variable. This can be numerical, a string (letters), or an object. When creating an object your
assigning that variable the properties of something that is inherent to the WMI objects. Think of it as
renaming a file (the WMI object) and then modifying if that file is read-write, read, or full control. The file
permission are properties of the object that is the file. Now lets begin…

Start-Transcript “C:\FileManagementP3.txt

Create your directory that you are going to share:

New-Item –path “c:\temp\” –itemtype “Directory”

To get a list of the currently shared files type the following command:

get-WmiObject -class Win32_Share | sort type, name

The following commands reveals the WMI.create method and the differing portions of this command:

$objWMI = [wmiClass] 'Win32_share'


$objWMI |gm -memberType method |format-List

The following commands set variable and the finally create the network shared folder:

$FolderPath = "C:\Temp"
$ShareName = " Temporary "
$Type = 0
$objWMI = [wmiClass] 'Win32_share'
$objWMI.create($FolderPath, $ShareName, $Type)

Verify that you have created the shared folder:

get-WmiObject -class Win32_Share | sort type, name

The following commands remove the shared drive you just created:

$ShareName = "Temporary"
$ShareDel = get-WmiObject Win32_Share -filter "Name ='$ShareName' "
$ShareDel.delete()

Verify that you have removed the shared folder and stop your transcript:

get-WmiObject -class Win32_Share | sort type, name


Stop-transcript

You might also like