Part III
Part III
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
To get a list of the currently shared files type the following command:
The following commands reveals the WMI.create method and the differing portions of this command:
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)
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: