Forum Replies Created
-
AuthorPosts
-
Another option would be to go old school and use NET USER
PowerShell1NET USER $UserName $NewPass /DOMAINDo you have read permissions on the file in its new location? Can you browse to it and open it in notepad?
November 26, 2015 at 3:46 am in reply to: Start-Process "Positional parameter cannot be found" error… #32302Start-Process -Credential ($credentials) -FilePath “\\server1\msi\New_Machine\$Greenshot” /ArgumentList “$GreenshotArgList”
Use -ArgumentList instead of /ArgumentList.
Forgive me, I’m not going to tell you how to do it.
What I will do is show you how you can find out how to do it. PowerShell has a powerful help system which allows you to discover commands (which PowerShell calls cmdlets) and how to use them. A good starting point for you would be the command
PowerShell1Get-Help *copy*This will search the help files for all references to ‘copy’. From those results, you should be able to work out which command you can use to copy items (that’s a hint!) from one location to another. PowerShell provides examples of how to use the commands and you can see those with
PowerShell1Get-Help Cmdlet-Name -ExamplesLet us know how you get on.
PowerShell12345678clear$file = get-Content 'c:\Computers.txt' # List of Computersforeach ( $node in $file) {get-WmiObject win32_logicaldisk -ComputerName $node |ft SystemName,DeviceID,@{Label="Total SIze";Expression={$_.Size / 1gb -as [int] }},@{Label="Free Size";Expression={$_.freespace / 1gb -as [int] }} -autosize |Out-File C:\report.txt -append -noclobber }Codeweavers is nearly there but you need to be outputting the data to the file at the end of each iteration of the foreach loop.
November 21, 2015 at 3:00 pm in reply to: Automate windows operations to run when an F key is pressed #32176I’m afraid it’s not a PowerShell solution but have a look at AutoHotKey.
Event locations are listed on the Eventbrite Page.
The organiser posted his e-mail address in this article announcing the event if you need to make direct contact.
November 6, 2015 at 4:14 am in reply to: Working with a txt file, search in string and formatted output #31740You can still use Curtis’s solution, but instead of replacing the colon and space with nothing replace it with a tab, using `t. e.g. to add two tabs.
PowerShell1$input -replace ": ","`t`t" | Out-file F:\__temp\outputfile.txtNovember 5, 2015 at 4:09 am in reply to: Extracting "color representation" property in of an image #31705From my testing that error was generated when the script attempts to process a file that is not an image. You will need to add code to skip files that are not supported. A list of supported images types can be found here:
https://msdn.microsoft.com/en-us/library/at62haz6(v=vs.110).aspxNovember 4, 2015 at 8:42 am in reply to: Extracting "color representation" property in of an image #31664I just tested it with PS2EXE from the TechNet Gallery and you’re right, you will need to add
PowerShell1Add-Type -AssemblyName System.DrawingPlace it at the top of the function declaration after
PowerShell1Param([string[]]$folder)Also, a minor thing, in the please wait message ‘untill’ should only have one ‘l’ 🙂
November 4, 2015 at 6:05 am in reply to: Extracting "color representation" property in of an image #31650What are you using to turn the PowerShell code into an exe?
I would use Robocopy. You’re almost certainly going to want to be using its wait and retry switches and its logging functionality for this type of migration. The /COPYALL switch will allow you to retain security and timestamps and attributes..
Where is the $? Is it a) \\oldserver\home$\ or b) \\oldserver\home\$?
If it’s a) then robocopy \\oldserver\home$\ \\newserver\home /e /copyall will rename on the fly.
If it’s b) it’s a little trickier. I’d be inclined to do something like:
PowerShell123456$folders = (Get-ChildItem \\oldserver\home\ -directory).nameforeach ($folder in $folders) {$newfolder = $folder.replace('$','')robocopy "\\oldserver\home\$folder" "\\newserver\home\$newfolder" /e /copyallBy the way, are you sure you want to remove the $? It’s used to hide the folder(s) – this is generally a good thing for home folders.
November 2, 2015 at 11:20 am in reply to: Extracting "color representation" property in of an image #31603I think I’ve got it working. In Code 1, after the line
PowerShell1$a=0Add the following:
PowerShell1234567891011121314151617181920$fileName = "$($objFolder.Self.Path)\$($objFolder.getDetailsOf($File, 0))"$photo = [System.Drawing.Image]::FromFile($fileName)# Color Spacetry {$colorProperty = $photo.GetPropertyItem(40961)if ($colorProperty -ne $null) {$colorSpace = [System.BitConverter]::ToUInt16($colorProperty.Value, 0)}if ($colorSpace -eq "1") {$colorSpace = "sRGB"}if ($colorSpace -eq "2") {$colorSpace = "Adobe RGB"}if ($colorSpace -eq "65535") {$colorSpace = "Uncalibrated"}$cs = @{'ColorSpace' = $colorSpace}} #end trycatch {$cs = @{'ColorSpace' = 'Property Not Set'}} #end catch$FileMetadata | Add-Member $csI had to add the try/catch because an exception was generated if the file did not have that property set. I would recommend additional error handling to skip files that are not images, these generated an out of memory exception when I tested the script.
October 14, 2015 at 2:13 am in reply to: script to enable Remote desktop option under system properties #30771I need a cold beer.
The hard work has been done for you. Google threw up this:
TechNet Blog – Checking and Enabling Remote Desktop With PowerShell.The same registry keys are using in Windows 7, I believe.
Not quite sure what you mean by ‘for select users’; this is a per machine setting. Remote access can be restricted to specific users by restricting membership of the local security groups. e.g. Members of Local Administrators will be able to connect and so will members of Remote Desktop Users.
This isn’t really a PowerShell question, I think you’ll have better luck in an iTextSharp forum. It looks like stackoverflow has an active iTextSharp community.
-
AuthorPosts