if((Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Google\Chrome").ManagedBookmarks -like
’[{"topleve_name":"Bookmarks"},{"url":"https://www.google.com","name":"Google"}]‘){
Write-out $true
}else
{
Write-Output $false
}
For example because in the scripts include {[ I can't run it success or share I format to string first?
I understand because it's old fashion tech that's why cacls retired but still working at my batch. I tried this way icacls $env:USERPROFILE\AppData\Roaming\vlc /inheritance:r /deny "$($env:USERNAME):F" if same permission as my batch icacls $env:USERPROFILE\AppData\Roaming\vlc /inheritance:r /deny "$($env:USERNAME):(OI)(CI)(F)"
Thank you for your suggestion but the app is installed for per user instead of local machine(i.e OneDrive) we can't use Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -match "OneDrive"} to find it at all. If I create script as app or package to deploy it when I choose user's right it works but popup UAC or choose administrative right it doesn't work because in administrator's path there is no OneDrive installed( As I mentioned the app installed for per user instead of local machine)
Thank you for your help but if we change LUA we must reboot it. I found the way to achieve my goal
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
ConsentPromptBehaviorUser DWORD
0 = Automatically deny elevation requests
1 = Prompt for credentials on the secure desktop
3 = Prompt for credentials (default)
https://www.tenforums.com/tutorials/112634-change-uac-prompt-behavior-standard-users-windows.html
I changed default value 3 to 0 (Needn't reboot)
Thank you for your reply
Yeah I also want to achieve via PowerShell
We can compare file hash
For example
Variables
$fileA = "C:\Users\Public\Desktop\pdf.pdf"
$fileB = "\\shared\ABC.pdf"
if(Test-Path 'C:\Users\Public\Desktop\ABC.pdf')){
write-output: "File exists "
}
{ Copy-Item ....
}
if((Get-FileHash $fileA).hash -ne (Get-FileHash $fileB).hash)
Remove-Item .....
Copy-Item ......
{
}
My logic
Situation 1 If file ABC.pdf not exist on public desktop copy file from shared folder
write-output :"File has been copied"
Situation 2 If file ABC.pdf exist on public desktop we should compare file hash
if file hash is different we should delete ABC.pdf and copy file from shared folder
write-output :"File has been updated"
else write-output : Files are the same
How can I run the PowerShell because there are two if conditions?