Hi,
Im fairly new to powershell but am looking to create a script which can look in a directory of photos which are namedsamaccountname.jpg. What I want to do is run a script which looks at the filename, matches it to samaccountname and import the photo.
This is what I have so far, but as I expected I am having issues:
$SAM = Get-Mailbox | select samaccountname
$Files = Get-ChildItem c:\photos | Select-Object Name
$Path = "C:\Photos\$SAM.jpg"
foreach ($file in $files) {([Byte[]] $(Get-Content -Path "$SAM" -Encoding Byte -ReadCount 0))}
At C:\Photos\photo1.ps1:4 char:40
+ foreach ($file in $files) {([Byte[]] $(Get-Content -Path "$SAM" -Encoding Byte - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Photos\ ... :String) [Get-Content], DirectoryNotFo
undException
+ FullyQualifiedErrorId : GetContentReaderDirectoryNotFoundError,Microsoft.PowerShell.Commands.GetContentCommand
Looks like it is not concatenating the path correctly. Any ideas what I can do?
Cheers