powershell-3.0

How can I copy from local to a remote location with credentials in PowerShell?

ⅰ亾dé卋堺 提交于 2020-01-04 05:23:27
问题 I am a fresh beginner to PowerShell. I have username and password to reach a shared folder in a remote location. I need to copy the file foo.txt from the current location to \\Bar.foo.myCOmpany.com\logs within a PS1 script that is written for Powershell v3.0 . How can I achieve this? 回答1: Copy-Item doesn't support the -credential parameter, This does parameter appear but it is not supported in any Windows PowerShell core cmdlets or providers" You can try the below function to map a network

PathTooLong error with Get-ChildItem in PowerShell v3, but not v2

时间秒杀一切 提交于 2020-01-04 01:55:15
问题 On a Windows Server 2008 R2 VM, I upgraded PowerShell to v3 hoping to take advantage of the Get-ChildItem (gci) performance improvement. This line ran without error in v2: $search = gci $dir -recurse -exclude "*.mdf" | where {$_.length -gt 100mb} After upgrading to v3, why does the same line give this error? The $dir value is unchanged. gci : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less

How do you increase the number of processes in parallel with Powershell 3?

佐手、 提交于 2020-01-03 18:42:13
问题 I am trying to run 20 processes in parallel. I changed the session as below, but having no luck. I am getting only up to 5 parallel processes per session. $wo=New-PSWorkflowExecutionOption -MaxSessionsPerWorkflow 50 -MaxDisconnectedSessions 200 -MaxSessionsPerRemoteNode 50 -MaxActivityProcesses 50 Register-PSSessionConfiguration -Name ITWorkflows -SessionTypeOption $wo -Force Get-PSSessionConfiguration ITWorkflows | Format-List -Property * Is there a switch parameter to increase the number of

Powershell - Find the next Friday

被刻印的时光 ゝ 提交于 2020-01-03 17:39:36
问题 Hoping this won't be too difficult but I am writing a script that queries user information from the domain and exports to CSV. The script is run by our administrative staff and all they need to input into the script is the username. The tricky part is that I need the CSV to be named based on the coming Friday. Note: I am in Australia so my date format is DD-MM-YYYY The way I am currently looking at going about it is as below: # Grab the Script Run Timestamp $ScriptRuntime = Get-Date -Day 4

Powershell - Find the next Friday

别来无恙 提交于 2020-01-03 17:36:30
问题 Hoping this won't be too difficult but I am writing a script that queries user information from the domain and exports to CSV. The script is run by our administrative staff and all they need to input into the script is the username. The tricky part is that I need the CSV to be named based on the coming Friday. Note: I am in Australia so my date format is DD-MM-YYYY The way I am currently looking at going about it is as below: # Grab the Script Run Timestamp $ScriptRuntime = Get-Date -Day 4

Pass strings by reference in Powershell?

烈酒焚心 提交于 2020-01-03 06:48:11
问题 How can I pass strings by reference to the parent scope? This doesn't work since strings are not acceptable "values". function Submit([ref]$firstName){ $firstName.value = $txtFirstName.Text } $firstName = $null Submit([ref]$firstName) $firstName Error: "Property 'value' cannot be found on this object; make sure it exists and is settable" Doing this doesn't give an error but it doesn't change the variable either: $firstName = "nothing" function Submit([ref]$firstName){ $firstName =

Stripping value in PS and comparing if it is an integer value

倾然丶 夕夏残阳落幕 提交于 2020-01-03 05:50:12
问题 I am running PS cmdlet get-customcmdlet which is generating following output Name FreeSpaceGB ---- ----------- ABC-vol001 1,474.201 I have another variable $var=vol Now, I want to strip out just 001 and want to check if it is an integer. I am using but getting null value $vdetails = get-customcmdlet | split($var)[1] $vnum = $vdetails -replace '.*?(\d+)$','$1' My result should be integer 001 回答1: Assumption: get-customcmdlet is returning a pscustomobject object with a property Name that is of

How to remove user profile completely from the Windows 10 computer?

穿精又带淫゛_ 提交于 2020-01-03 01:42:32
问题 I want to remove local user in windows 10 computer through powershell. I have tried command Get-WMIObject -class Win32_UserProfile | Where {((!$_.Special) -and ($_.LocalPath -eq "C:\\Users\\$user") -and ($_.LocalPath -ne "C:\\Users\\UpdatusUser"))} | Remove-WmiObject The Above command removes local user sucessfully. But it can't delete C:\Users\$user\AppData Is there any workaround/hack to remove user/AppData folder. I have also tried removing folder after successful deletion of user, but I

How to hide tabs on Powershell GUI?

℡╲_俬逩灬. 提交于 2020-01-02 06:08:19
问题 Ok, I created a powershell script and I am trying to make the main interface use a tabbed layout. I got all functionality i want working except i want to hide the tabs up top and use the buttons on the side to switch tabs. I already successfully have the buttons on the side selecting the different tabs, but i can't figure out how to hide the tabs up top? Anyone have any way how to do this??? Picture Says It Best: References: http://msdn.microsoft.com/en-us/library/system.windows.forms.tabpage

How to hide tabs on Powershell GUI?

*爱你&永不变心* 提交于 2020-01-02 06:07:35
问题 Ok, I created a powershell script and I am trying to make the main interface use a tabbed layout. I got all functionality i want working except i want to hide the tabs up top and use the buttons on the side to switch tabs. I already successfully have the buttons on the side selecting the different tabs, but i can't figure out how to hide the tabs up top? Anyone have any way how to do this??? Picture Says It Best: References: http://msdn.microsoft.com/en-us/library/system.windows.forms.tabpage