powershell-4.0

Error opening excel in powershell

扶醉桌前 提交于 2019-12-05 04:01:21
I need to open excel file with CorruptLoad paramterer from powershell-script. But when I try to make it, I get an error Exception calling "Open" with "15" argument(s): "open method workbooks class failed" . This error occurs only when I call Open with all 15 arguments. And when I try to open the same excel file with VB.net program with 15 arguments or with specifying value of named argument CorruptLoad , there is no problem! I'm using powershell v 4.0 , Office 2010 with SP2 and .NET Framework 4.5.2 . Here is my powershell code: $excel = New-Object -ComObject Excel.Application $excel.Visible =

Change the current culture of a Powershell session, v3.0+ specific

為{幸葍}努か 提交于 2019-12-05 02:01:25
问题 I want to change the culture of accepted data and errors in my current interactive Powershell session. I am aware of this question powershell : changing the culture of current session and of this question Changing current culture on SuperUser. The main problem that it doesn't work with Powershell 3.0 and 4.0. PS C:\users\me\Documents> [system.threading.thread]::currentthread.currentculture LCID Name DisplayName ---- ---- ----------- 1049 ru-RU Русский (Россия) PS C:\users\me\Documents>

PowerShell PSScriptRoot is null

 ̄綄美尐妖づ 提交于 2019-12-04 23:50:04
When I run $PSScriptRoot it returns null . I am using PS version 4. $val = Join-Path -Path $PSScriptRoot WebPlatformInstaller_amd64_en-US.msi Error Join-Path : Cannot bind argument to parameter 'Path' because it is an empty string. If using ISE use: $psISE.CurrentFile.FullPath When ISE is launched, $psISE is created and can be used to determine the current path of the ISE instance. This was introduced in version 3.0. See ISE Object Model Hierarchy If you wanted to get the path in either shell or ISE you could use something like this: if ($psISE) { Split-Path -Path $psISE.CurrentFile.FullPath }

Trying to upload files to subfolder in Sharepoint Online via Powershell

╄→尐↘猪︶ㄣ 提交于 2019-12-04 20:41:31
I am new to Powershell and I am trying to upload files from a local folder into Sharepoint online. I seem to get the files into the library, but not into the second subfolder where i want them. Script so far: #Specify tenant admin and site URL $User = "admin@contoso.no" $SiteURL = "https://contoso.sharepoint.com" $Folder = "E:\LocalFolder" $DocLibName = "Libraryname" $FolderName = "Folder/SubFolder" #Add references to SharePoint client assemblies and authenticate to Office 365 site – required for CSOM Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI

Change the current culture of a Powershell session, v3.0+ specific

99封情书 提交于 2019-12-04 15:08:53
I want to change the culture of accepted data and errors in my current interactive Powershell session. I am aware of this question powershell : changing the culture of current session and of this question Changing current culture on SuperUser. The main problem that it doesn't work with Powershell 3.0 and 4.0. PS C:\users\me\Documents> [system.threading.thread]::currentthread.currentculture LCID Name DisplayName ---- ---- ----------- 1049 ru-RU Русский (Россия) PS C:\users\me\Documents> [system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US" PS C:\users

How does -InputObject parameter of the Sort-Object cmdlet work?

本秂侑毒 提交于 2019-12-04 04:18:47
问题 PowerShell 4.0 I read about Sort-Object cmdlet here (TechNet page). I don't understand how to use -InputObject parameter. That page hasn't examples for it. Also I didn't find this info in Internet. I would be very grateful for the examples of its using, or for the links to Internet pages with that info. I have tried to use it how I understand its purpose (according documentation): $items = ('a','b','c','d') $result = sort -InputObject $items -Descending But the result variable has the same

How to cat a UTF-8 (no BOM) file properly/globally in PowerShell?

老子叫甜甜 提交于 2019-12-03 17:21:02
问题 Create a file utf8.txt . Ensure the encoding is UTF-8 (no BOM). Set its content to € In cmd.exe : type utf8.txt > out.txt Content of out.txt is € In PowerShell (v4): cat .\utf8.txt > out.txt or type .\utf8.txt > out.txt Out.txt content is € How do I globally make PowerShell work correctly? 回答1: Windows PowerShell, unlike the underlying .NET framework [1] , uses the following defaults : on input : files without a BOM (byte-order mark) are assumed to be in the system's default encoding ,

How do I get PowerShell 4 cmdlets such as Test-NetConnection to work on Windows 7?

一个人想着一个人 提交于 2019-12-03 16:36:49
问题 The situation. On a Windows 7 SP1 machine, I have updated with Windows6.1-KB2819745-x64-MultiPkg.msu. Furthermore, in PowerShell $PSVersionTable now reports ‘PSVersion 4.0’. At present, my conclusion is that many PowerShell 4 cmdlets such Test-NetConnection, will only work on Windows 8.1. However, I was wondering if there was a work-around whereby I could import PowerShell 4 modules on my Windows 7 machine. 回答1: You cannot. They rely on the underlying features of the newer OS (8.0 or 8.1) and

Using Windows Forms Locks up PowerShell ISE minutes after script has terminated

纵然是瞬间 提交于 2019-12-03 15:14:56
问题 I have an interesting issue here. I'm creating a calendar picker for use when we create accounts. It works fine and is still in progress but I have noticed that when I run the script in powershell ISE, after a few minutes it locks up (I am able to edit and save the code for a few minutes prior to that). There is nothing in the event log. I get a dialog box saying that powershell is non responsive. Memory usage seems normal as well. I do not know what is happening. This occurs no matter how I

Using Windows Forms Locks up PowerShell ISE minutes after script has terminated

社会主义新天地 提交于 2019-12-03 10:57:45
I have an interesting issue here. I'm creating a calendar picker for use when we create accounts. It works fine and is still in progress but I have noticed that when I run the script in powershell ISE, after a few minutes it locks up (I am able to edit and save the code for a few minutes prior to that). There is nothing in the event log. I get a dialog box saying that powershell is non responsive. Memory usage seems normal as well. I do not know what is happening. This occurs no matter how I run Powershell ISE (Run as Administrator, Run as another account, and normal ISE) I am running windows