When you post code, please use the "Code Sample" editor (it's the 5th icon from the left on the Format Bar and has the graphic "101 010"). Using the default (plain text) editor will mangle your code is strange ways. It also makes it difficult to separate explanatory text from the code.
First, the placement of the "{" and "}" characters was wrong.
Second, when you use the Select-Object cmdlet the result is a PSCustomObject and not the simple string value you expected. In your code, you'd have to use $PLW.name to get at that string. It also means that the test to see if $AS_Shares contains $PLW will always fail because your code was comparing an array of PSCustomObjects to see if another PSCustomObject was in the array.
I think this is what you intended:
$AS_Shares = Get-SmbShare -CimSession $server | Select-Object -Expand name
$AS_PLW = Get-ChildItem -Path \\$server\PLW$ | Select-Object -Expand name
ForEach ($PLW in $AS_PLW) {
if ($AS_Shares -icontains $PLW) {
Write-Host $PLW is shared
}
else {
Write-Host $PLW not shared
}
}
I think you'd benefit greatly by downloading this free PDF: Windows-PowerShell-4
Read the 1st half and do the exercises before moving on to the 2nd half.