Custom Properties of Office Documents
Script not working to export folder list on which xxx user dont have access
Hi Team,
I am in process to create script to export list of folders where my domain user dont have access in all folders including folders. From below script I am able to export list of folders where XXX user
have access in folders with subfolders.
My Script :
Get-ChildItem 'FolderPath' -Recurse -ErrorAction SilentlyContinue -ErrorVariable err | Where-Object {(Get-Acl $_.FullName).Access | Where-Object {$_.IdentityReference -eq 'Domain\XXXuser'} } | Select -Expand FullName > Pathtoexportlist.csv
foreach ($errorRecord in $err)
{
if ($errorRecord.Exception -is [System.IO.PathTooLongException])
{
Write-Warning "Path too long in directory '$($errorRecord.TargetObject)'."
}
else
{
Write-Error -ErrorRecord $errorRecord
}
}
Please help me to modify this script to export list of folder where XXX user dont have permission.
Thanks,
Yogesh
Thanks, Yogesh M
How do I use a rgb(116, 0, 110) in code for Powershell console.BackgroundColor?
I can use PowerShell Property dialog to select a red green blue BackgroundColor but in code I only have[System.ConsoleColor]::
- Black
- Blue
- Cyan
- DarkBlue
- DarkCyan
- DarkGray
- DarkGreen
- DarkMagenta
- DarkRed
- DarkYellow
- Gray
- Green
- Magenta
- Red
- White
- Yellow
I want like a .NET [System.Drawing.Color]::MediumPurple
or
rgb(116, 0, 110)
David Morrow
Get modified dates for a list of files
I am trying to come up with a way to use a list of files for the input and gather a list of modified dates for those files. I'd like it to take up a single line but if that's not realistic, then so be it. I thought I had a solution to the problem but it doesn't work like I think it should and I'm not sure why. I came up with two potential solutions but neither one work.
- Get-Content c:\Users\me\Desktop\listoffilesandpath.txt | Foreach-Object {Write-Host $_.LastWriteTime}
- Get-Content c:\Users\me\Desktop\listoffilesandpath.txt | Foreach-Object {Get-ChildItem $_.LastWriteTime}
The first doesn't display anything at all and the second gets the write times for everything in the directory that I'm in - neither seems to use the non-empty list located at c:\Users\me\Desktop\listoffilesandpath.txt. Clearly there is something that I don't understand about how these commands interact with one another. What am I doing wrong here?
Get all meetings and organizer from room mailbox
To fix a little mess we made, we need to remove a bunch of room mailboxes and recreate them.
It's probably impossible to automatically recreate all meeting afterwards in the meeting rooms with the correct organizer and attendees (if not, please do tell me!). So I'd like to get a list of all meetings and its organizer from each room mailbox.
How can I do this in Powershell?
Regards,
Ruben
Get-Content filtering
Hi Everyone,
With Get-Content -Path C:\users\administrator\symantec\symantec endpoint protection\*.log | where-object {$_ -like '*scanning complete:*'} i manage to get the below chunk of string
2E050A0A2F26,2,2,1,Jupiter,internet,,,,,,,,,,,16777216,"Scan Complete: Risk: 0 Scanned:0 Files/folder/drives Omitted : 0 Trusted
Files Skipped: 0", 14353654624,0:0:0:0,,,,,{ABCDDDEA-3123-4***}
Is there anyway to further down the string by delimiter comma to achieve only"Scan Complete: Risk: 0 Scanned:0 Files/folder/drives Omitted : 0 Trusted
Files Skipped: 0"?
Script output on same line.
Hi.
The following is part of a script we use to create Outlook email signatures when people log on to their PC's. It pulls various information from AD and an image from a central server then creates the signature.
My issue is that the following is all on a single line where before I added a new website link, the URL line, and Accreditation are on seperate lines. What have I missed?
'URL5 objSelection.Font.Name = "Arial" objSelection.Font.Bold = False objSelection.Font.Color = RGB(255,102,0) objSelection.Font.Size = 9 objLink = objSelection.Hyperlinks.Add(objSelection.Range,"http://www.swanndirect.com",,"Swann Direct", "www.swanndirect.com") objSelection.TypeText Space(2) 'Event 'Set objLink = objSelection.Hyperlinks.Add(objSelection.InlineShapes.AddPicture("\\server.site.domain.local\signatures$\Event.jpg"), "http://www.swanngroupltd.com",,,"") 'objSelection.TypeText Chr(11) 'objSelection.TypeText Chr(11) 'Accreditation Logo Set objLink = objSelection.Hyperlinks.Add(objSelection.InlineShapes.AddPicture("\\server.site.domain.local\signatures$\Sig-Acc.jpg"), "http://www.swanngroupltd.com",,,"")
So the output should be URLs 1 to 5 on one line, Event (when used) on another line and Accreditation on a seperate one. Before I added a new URL and all of a sudden its showing on the same line, what did I break???
Thanks.
Why is Get-ADGroupMember so slow?
I tried to write a script that does some AD stuff, and the script took like half an hour to run when I expected it to take maybe half a minute. I debugged the whole thing and found out that the Get-ADGroupMember cmdlet is taking up 99% of that runtime.
I write the following script to test this and compare the Powershell method with the .NET one:
$domain = "domain.local" $groupname = "SomeGroup" $start = Get-Date $group1 = Get-ADGroupMember $groupname "With Get-ADGroupMember " + ((Get-Date) - $start).TotalMilliseconds $start = Get-Date Add-Type -AssemblyName System.DirectoryServices.AccountManagement $pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Domain, $domain) $group2 = [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($pc, [System.DirectoryServices.AccountManagement.IdentityType]::Name, $groupname) #$group2.Members.GetEnumerator() | % { $_.DisplayName } "With .NET " + ((Get-Date) - $start).TotalMilliseconds
If I use that on a group with 7 members, Powershell takes 1.7 seconds (!) to run while the native .NET does it in 13 milliseconds.
If I try a group with 300 members, Powershell takes 52 seconds and .NET 18 milliseconds.
Does anyone know if it's possible to get Powershell to improve on that? Because right now I'm tempted to homebrew my own cmdlet based on .NET.
Issues modifying local security settings with secedit
Automate modifying Launch and Activation Permissions in Component Services
I need to automate the following process in C# (or some programming language) and the C# forum suggested I try using scripting (http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/54196c55-2608-4266-a016-0155f75b4391/):
- In the Administrative Tool - Component Services
- I manually:
- Open Component Services tree to Computers
- Open Computers tree to My Computer
- Right click on My Computer and select properties
- Select COM Security tab in My Computer Properties tab dialog
- Select Edit Limits button under Launch and Activation Permissions(not Access Permissions)
- Under the Lauch and Activation Permission dialog select the Add button
- Enter "admin" (this is a valid account) in the edit filed labeled: Enter the object names to select
- Select the OK button
- Select "admin" in the Group or user names list
- And check Allow for all Permissions to admin (Local Launch, Remote Launch, Local Actication, Remote Activation)
Does anyone know how to do this process with scripting?
C# forum suggests: "you could perhaps find more easily someone that used those classes in an admin scripting group "
This is a long complicated process that I need to automate in C# and I cannot find how to even start. Do you have any insights?
Need a startup script for WIndows 2008 R2
1) enter IP address
2) enter IP Netmask
3) enter IP GW
4) enter DNS primary
5) enter DNS secondary
6) enter computername
7) Join computer to domain ( prompts for domain name and username)
8) Move computer OU prompt for OU
I gotta assume its been done...
Executing a .cmd/.bat file remotely to install patches
So essentially I need to copy a .cmd or .bat file to a server and execute it remotely. The .cmd/.bat uses wusa to install windows patches and works when run locally.
I can get the file to copy, and the script executes without error, but It does not actually install the patches. I've tried re-writing the .cmd file as a .ps1 but it has the same result.
Copy-Item -Path "C:\scripts\TESTpatches.cmd" -Destination \\$computer\c$\temp\TESTpatches.cmd Invoke-Command -ComputerName $computer -ScriptBlock { Invoke-Item \\$computer\c$\temp\TESTpatches.cmd }
FYI: the .cmd is using wusa.exe to install specific patches stored on a file server.
I have also tried copying the patches locally to the server as well, but it has the same result.
wusa.exe \\SERVER1\script$\_WindowsHotfix\MS16-055\Windows6.1-KB3156016-x64.msu /quiet /norestart wusa.exe \\SERVER1\script$\_WindowsHotfix\MS16-055\Windows6.1-KB3156019-x64.msu /quiet /norestart wusa.exe \\SERVER1\script$\_WindowsHotfix\MS16-051\IE11-Windows6.1-KB3154070-x64.msu /quiet /norestart
Any assistance would be appreciated
help to need new create script
Hello team,
I need to set new script in member server and it should get applied on Domain controller
below is the creteria
Module 1 : Check if the Computer is inactive > 90 days ( LastLogon and Password Reset ) then disable it and move it Disabled OU
Details - SCript need to check on daily basis if any computer object is inactive for 90 days based on AD attribute Last logon and Password reset and if yes , disable those computer object and move it to disabled OU ( i will modiy and enter the disable OU)
Module 2 : Script to disabled all Computer Object under Disabled OU.
Details - and in the same script we need to add this second condition, that in the disabled OU, the computer object cannot be enabled by anyone
Please assist me on this
Thanks in advance
NA
Error pulling AD group members
Hello all. I have a script that reads a text file with a list of AD security groups, and then exports the members to another text file. It works pretty well, but I have some issues I could use help with. The main one is I occasionally get the error "Active Directory: The directory property cannot be found in the cache" on the "arrMemberOf" line. If I go into the source text file and remove the group the script got hung on, I can start the script again and it will work. I was hoping for ideas to either fix this error message, or if not to maybe have the script skip the offending group. And as an extra bonus, if the script skips a group would there be a way to write the names of the skipped groups to a third text file? Thank you in advance, any help is much appreciated. Below is the script I'm running:
' VBscript to output group membership from multiple groups
' Put list of groups' FQDNs in *path to source.txt*
' Results will be output to *path to output.txt*
Dim fso
Dim objReadFile
Dim objWriteFile
Dim strGroup
Dim strGroupFQDN
Dim WshShell
Const ForReading = 1
Const ForAppending = 2
Const ForWriting = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set objReadFile = fso.OpenTextFile("*path to source.txt*", ForReading)
Set objWriteFile = fso.OpenTextFile("*path to object.txt", ForAppending, True)
Do until objReadFile.AtEndOfStream
strGroupFQDN = objReadFile.ReadLine
Set objGroup = GetObject("LDAP://" & strGroupFQDN)
arrMemberOf = objGroup.GetEx("member")
objWriteFile.Write strGroupFQDN & vbCrLf & vbCrLf
For Each strMember in arrMemberOf
objWriteFile.Write strMember & vbCrLf
Next
Set objGroup = Nothing
objWriteFile.Write vbCrLf & vbCrLf
Loop
objReadFile.Close
objWriteFile.Close
Wscript.Quit
Install software at Computer Startup
I'm trying to install ZixSelect add-on for Outlook, but I am having a difficult time automating this.
I'm successful if I do the following:
1. Log in as local admin
2. Start > Run > Type: "\\SERVER\Share\ZSO_Install\ZSO_6.1.0.33.exe" -s -f1".\setup.iss" > OK
The installation works correctly (it installs the MS Visual Studio 2010 Tools for Office Runtime, and ZixSelect for Outlook)
I copied and pasted the same line into a batch file (ZSO_Install.bat), and created a Computer Start Script GPO (Comp Config > Policies > Windows Settings > Scripts (Startup/Shutdown) > Startup. I then saved the batch file to the SYSVOL location. I ran GPUPDATE /FORCE on the computer, turned off UAC, restarted, and then no apps installed. I'm trying different variations, but not being successful.
Anyone have any suggestions?
Hey, Scripting Guy! I need a way to create a .zip archive of a different files with different naming convention in Powershell
Hey, Scripting Guy! I need a way to create a .zip archive of a folder
Take a folder Source which has multiple files extensions that has more than a months older than the current date, zip it and move the zip to a Destination. Then delete the log file from the source drive. This will become a scheduled nightly task on a few of our servers. I am trying to do this not able to achieve the solution. Could any one can help me. Appreciate your help. Thanks in Advance..... !!!
Example:-
Test1_201601.txt
Test2_201605.txt
The both files has to read the file name and it has to zip into same test_201606.zip file
PowerShell - Easy way to output an array to CSV text file?
[array]$testArray = ,("one", "two", "three") $testArray += ,("1", "2", "3") Write-Host "testArray -" $testArray $testArray | Export-Csv "C:\test.csv"
Why does the test.csv file show these results:
#TYPE System.String Length 1 1 1
It displays the strings on the console:
testArray - one two three 1 2 3I've searched the net but all the solutions seem to require lots of complex code to make this happen. With so many things being so easy to do in PowerShell, I don't understand why this is so complicated.
Exporting member info of multiple adgroups using import-csv
I seem to always run into something when I try to use import-csv. My goal here is to get all of the ADUsers from multiple ADGroups and export that info to csv. My import csv, for example, is one column named 'Group'. I'd like the export to have 3 columns.. 'Group' 'ID' 'Name'. And to list the name of the first group (from import) in column A until the last member and then the name of the second group (from import) in column A next... so on and so forth. What I have currently get's all the user info the way that I want it but leaves column A blank so I can't decifer it. Below is my code so far:
$Groups = Import-Csv {file path}\GroupImport.csv $Groups | % {Get-ADGroupMember $_.Group} | select name | % {Get-ADUser -Identity $_.name -Properties * | select @{N="Group";E={$Group}}, @{N="ID";E={$_.name}}, @{N="Name";E={$_.surname + ", " + $_.givenName}} } | Export-Csv {file path}\GroupExport.csv -NoTypeInformation
Any advice or point in the right direction would help appreciated!
Cannot remotely invoke Windows Server Backup cmdlets on some Windows 2008 R2 machines.
I have been working on a variant of Alexandre Augagneur''s (www.alexwinner.com) backup script. I have it almost done, however I am having the strangest problem with some of my Windows 2008R2 servers. The Windows Backup cmdlets work fine from the machines console, but when invoked remotely from a invoke-command statement , they act as though the Backup cmdlets are not installed. It goes like this..
Invoke-Command -ComputerName orfsd-tst2 -Credential $MyCredential { import-module servermanager } Invoke-Command -ComputerName orfsd-tst2 -Credential $MyCredential { Add-PSSnapin Windows.ServerBackup } Invoke-Command -ComputerName orfsd-tst2 -Credential $MyCredential { get-wbjob } The term 'get-wbjob' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (get-wbjob:String) [], CommandNotFoundException+ FullyQualifiedErrorId : CommandNotFoundException+ PSComputerName : orfsd-tst2
Invoke-Command -ComputerName orfsd-tst2 {get-command *backup* }
Enter-PSSession orfsd-tst2
[orfsd-tst2]: PS C:\Users\lee\Documents> Add-PSSnapin Windows.serverbackup
[orfsd-tst2]: PS C:\Users\lee\Documents> get-command "*backup*"
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Add-WBBackupTarget 0.0 Windows.serverbackup
Cmdlet Get-WBBackupSet 0.0 Windows.serverbackup
Cmdlet Get-WBBackupTarget 0.0 Windows.serverbackup
Cmdlet Get-WBVssBackupOptions 0.0 Windows.serverbackup
Cmdlet New-WBBackupTarget 0.0 Windows.serverbackup
Cmdlet Remove-WBBackupTarget 0.0 Windows.serverbackup
Cmdlet Set-WBVssBackupOptions 0.0 Windows.serverbackup
Cmdlet Start-WBBackup 0.0 Windows.serverbackup
I get the same behavior with Powershell 3.0, or 5.0. This machine has 5.0 installed.
Any ideas?
Issues Submitting Login Form
Hi guys
I've decided to learn Powershell for an ETL workflow but I'm having trouble with the basics.
I receive the below error when attempting to Invoke-WebRequest:
[ERROR] Invoke-WebRequest : The remote name could not be resolved: 'logon'
Below is my script:
$sTarget = "http://www.lcbo.com/webapp/wcs/stores/servlet/en/sod/" $sLogin = "redacted" $sPassword = "redacted" function Main() { Write-Host "Logging into $sTarget" $htmlTargetLogin = Invoke-WebRequest $sTarget -SessionVariable session $htmlTargetLogin.Forms[0].fields["logonId"] = $sLogin $htmlTargetLogin.Forms[0].fields["logonPassword"] = $sPassword
$htmlTargetMain = Invoke-WebRequest $htmlTargetLogin.Forms[0].Action -WebSession $session -Body $htmlTargetLogin -Method Post return } Main
Any suggestions?
Thanks!
Simon