Glenn M
asked on
Need Powershell Script to pull TXT from Remote share location.
I have a PowerShell script that works perfectly when the TXT file is found locally. I want to have the TXT file be remote, the script is unhappy.
The errors I get are:
Access is denied
+ CategoryInfo : PermissionDenied: (\\server\files\temp\text. txt:String ) [Get-Content], UnauthorizedAcce
ssException
+ FullyQualifiedErrorId : ItemExistsUnauthorizedAcce ssError,Mi crosoft.Po werShell.C ommands.Ge tContentCo mmand
+ PSComputerName : 10.10.8.95
Cannot find path '\\server\files\temp\text. txt' because it does not exist.
+ CategoryInfo : ObjectNotFound: (\\server\files\temp\text. txt:String ) [Get-Content], ItemNotFoundExcept
ion
+ FullyQualifiedErrorId : PathNotFound,Microsoft.Pow erShell.Co mmands.Get ContentCom mand
+ PSComputerName : 10.10.8.95
Script is:
The errors I get are:
Access is denied
+ CategoryInfo : PermissionDenied: (\\server\files\temp\text.
ssException
+ FullyQualifiedErrorId : ItemExistsUnauthorizedAcce
+ PSComputerName : 10.10.8.95
Cannot find path '\\server\files\temp\text.
+ CategoryInfo : ObjectNotFound: (\\server\files\temp\text.
ion
+ FullyQualifiedErrorId : PathNotFound,Microsoft.Pow
+ PSComputerName : 10.10.8.95
Script is:
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
$TextFile = "C:\Temp\text.txt"
$Text = [System.Security.SecurityElement]::Escape((Get-Content -Path $TextFile -Raw))
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
# Gets the Template XML so we can manipulate the values
$ToastTemplate = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml()
$ToastTemplate = @"
<toast launch="action=viewAlarm&alarmId=3" scenario="alarm">
<visual>
<binding template="ToastGeneric">
<text>$($Text)</text>
<image placement="appLogoOverride" hint-crop="circle" src="https://picsum.photos/64?image=000" />
<image placement="hero" src="http://finalbca.16mb.com/noti2.png" />
</binding>
</visual>
<actions>
<action activationType="system" arguments="snooze" content="" />
<action activationType="background" arguments="dismiss" content="Dismiss"/>
</actions>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate)
$Notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)
$Notify.Show($ToastXml)
ASKER
Yes, I understand where I need to make the change, for example: $TextFile = "\\server\files\temp\text. txt"
My problem is that I DO have permissions to that share and I am running this as a "domain users" have RWXD permissions and access to that share.
I don't think NTFS or Share permissions are the issue here.
My problem is that I DO have permissions to that share and I am running this as a "domain users" have RWXD permissions and access to that share.
I don't think NTFS or Share permissions are the issue here.
Just double check you need permissions on the "security" tab and in the "share" tab of your shared folder
Probably is something related to double-hop.
https://stackoverflow.com/questions/7061668/powershell-doesnt-have-access-to-a-network-share?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
Probably is something related to double-hop.
https://stackoverflow.com/questions/7061668/powershell-doesnt-have-access-to-a-network-share?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
Ok did you check the link?
Try with this in front of the name
"Microsoft.PowerShell.Core \FileSyste m::\\<serv er>\<share dfolder>"
something like this in line 4:
"Microsoft.PowerShell.Core \FileSyste m::\\serve r\files\te mp\text.tx t"
Try with this in front of the name
"Microsoft.PowerShell.Core
something like this in line 4:
"Microsoft.PowerShell.Core
ASKER
forgive me... I'm not super savvy here.
I understand what needs to be replaced on line 4. The Part before that, where does that need to do?
I understand what needs to be replaced on line 4. The Part before that, where does that need to do?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was hoping that someone would put it all together, with the script I provided and the answers given. I am attempting to see if I can splice it is. I am assuming this will help. Thanks in advance...
$TextFile = "C:\Temp\text.txt"
to the remote computer in a shared drive with permissions.
The script is unhappy because you don't have access to that directory with the user that is running the script.
The error is pretty clear:
Access is denied
PermissionDenied: (\\server\files\temp\text.