Accessing data on SMB shares

In the Creating and securing SMB shares recipe, you created a share on FS1. Files shared using SMB act and feel like local files when you access the share, for example, via Explorer.

In this recipe, you access the Foo share on FS1 from the CL1 Windows 10 system you created in Chapter 1, Establishing a PowerShell Administrative Environment.

Getting ready

You should have completed the Creating and securing SMB shares recipe. Additionally, you should have the CL1 Windows 10 system up and working—you created this system in Chapter 1, Establishing a PowerShell Administrative Environment.

You should run this recipe in an elevated console.

How to do it...

  1. Examine the SMB client's configuration:
    Get-SmbClientConfiguration
  2. Set SMB signing from the client:
    $CHT = @{Confirm=$false}
    Set-SmbClientConfiguration -RequireSecuritySignature $True @CHT
  3. Examine the SMB client's network interface:
    Get-SmbClientNetworkInterface |
      Format-Table Friendlyname, RSS*, RD*, Speed, IpAddresses 
  4. Examine the shares provided by FS1:
    $FS1CS = New-CimSession -ComputerName FS1
    Get-SmbShare -CimSession $FS1CS
  5. Create a drive mapping, mapping R: to the share on the FS1 server:
    New-SmbMapping -LocalPath R: -RemotePath \FS1.Reskit.OrgFoo
  6. View the shared folder mapping on CL1:
    Get-SmbMapping
  7. View the shared folder's contents:
    Get-ChildItem -Path R:
  8. View the existing connections:
    Get-SmbConnection
  9. Show what files and folders are open on FS1:
    Notepad R:Foo.Txt   # created in an earlier recipe
    Get-SmbOpenFile -CimSession $FS1CS

How it works…

In step 1, you view the SMB client configuration, which looks like this:

How it works…

In step 2, you explicitly set the SBM to require the signing of SMB packets. This step creates no output.

In step 3, you look at the SMB client's network interface details, which look something like this:

How it works…

In step 4, you set up a CIM session to FS1, then use that session to determine the shares being offered by FS1, which looks like this:

How it works…

In step 5, you create a new client-side drive mapping, mapping the R: drive on CL1 to the \FS1Foo share. The output looks like this:

How it works…

In step 6, you view the client-side drive mappings, which looks like this:

How it works…

In step 7, you use the Get-ChildItem cmdlet to view the contents of the R: drive, and see what files exist on the Foo share of FS1. The output of this step looks like this:

How it works…

In step 8, you open a file on R: in the Notepad drive and then use the CIM session (which you created in step 4) to view the open connections to FS1. The output looks like this:

How it works…

In the final step, step 9, you view the files and folders that are open on FS1, which looks like this:

How it works…

There's more...

In step 4, you create a CIM session from CL1 to FS1, and check which shares are provided by FS1. There's no cmdlet equivalent of the net view <servername> command.

In step 7, since you have set permissions, a regular domain admin account has no access. It needs to be part of the Sales or Salesadmin groups.

In step 9, you used Get-SmbOpenFile to see the files open on FS1. As you can see, details of the open file and the computer making the connection are clearly shown. You get both a full path for each open file or folder, as well as a share-relative path. What the output shows is that R:Foo.Txt from CL1 is C:FooFoo.Txt on FS1.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.80.209