search-mailbox command not work in my exchange 2010 sp1 - exchange-server

My search-mailbox command not work. the issue is like:
[PS] C:\Windows\system32>Search-Mailbox -Identity "abc" -SearchQuery "Subject:'test'"
Target mailbox or .pst file path is required.
+ CategoryInfo : InvalidArgument: (:) [], ArgumentException
+ FullyQualifiedErrorId : 78AF2AE3
At the same time, the command like get-mailbox has no problem.
Doese anybody can help?

The problem fixed by set target mailbox and folder. Use command like folloing:
Search-Mailbox -Identity "abc" -SearchQuery "Subject:'test mail'" -TargetMailbox "demo.xw" -TargetFolder "SearchLog"

Related

Make a copy of swapfile.sys to new location [File not found error]

In PowerShell, I am trying to make a copy of the Windows swapfile (swapfile.sys)
PS C:\> Copy-Item swapfile.sys -Destination C:\Users\
However, I recieve the error:
Copy-Item : Cannot find path 'C:\swapfile.sys' because it does not exist.
At line:1 char:1
+ Copy-Item swapfile.sys -Destination C:\Users\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\swapfile.sys:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
I can confirm the file exists with attrib *.sys
Perhaps this is due to the fact it is a hidden file, or a type of file that cannot be copied? I want to investigate this file with a HexEditor and was hoping to make a stand-alone copy for this.

AppxProvisionedPackage commands stuck on PowerShell and return DismInitialize failed

I am trying to install LOB UWP application
I used:
Add-AppxProvisionedPackage -Online -PackagePath "APPX_PATH"
-DependencyPackagePath "DEPENDENCIES"-SkipLicense
It worked for the first time, i even asked one of my colleagues to log in and the app was there.
But, after that, i tried to reinstall it with the same command. But the command refused to execute, it's just blinking and loading.
I tried other commands to get the packages or remove the package but all have the same behavior.
What could be a valid reason for that?
Get-AppXProvisionedPackage -Online | Select PackageName
Remove-AppxProvisionedPackage
-PackageName "PackageName" -Online -AllUsers
EDIT#1:I am getting the following error after waiting for long time and pressing PgDn or End buttons on keyboard.
Remove-AppxProvisionedPackage : DismInitialize failed. Error code = 0x80004005
At line:1 char:1
+ Remove-AppxProvisionedPackage -PackageName PACKAGE_NAME ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-AppxProvisionedPackage], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.RemoveAppxProvisionedPackageCommand

use PowerShell to save file in Visual Studio

Using Powershell from Package Manager Console I can open and close file:
$DTE.ExecuteCommand(“File.OpenFile”, $file)
$DTE.ExecuteCommand(“File.Close”)
But when I try to save it:
$DTE.ExecuteCommand(“File.Save”, $file)
or
$DTE.ExecuteCommand(“File.Save”)
I get error:
PM> $DTE.ExecuteCommand(“File.Save”) Command "File.Save" is not valid.
At line:1 char:1
+ $DTE.ExecuteCommand(“File.Save”)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
How I can save it?
Actually I want to save it in other encoding:
You can save the file with
$DTE.ExecuteCommand("File.SaveSelectedItems")
There is also
$DTE.ExecuteCommand("File.SaveAll")
If you're doing this only to change the file's encoding however, I would suggest simply running the following PowerShell code that doesn't require $DTE and Visual Studio at all.
$content = Get-Content -Path $file -Encoding String
Set-Content -Value $content -Path $file -Encoding UTF8

About MicrosoftTeams-TeamFunSettings

Today I found that the MicrosoftTeams powershell command Get-TeamFunSettings failed to run when the property GiphyContentRating value is "Allow all content".
Error info:
Get-TeamFunSettings : Error converting value "unknownFutureValue" to
type
'System.Nullable`1[Microsoft.TeamsCmdlets.PowerShell.Custom.Model.GiphyRatingType]'.
Path 'funSettings.giphyContentRating', line 1, position 844. At line:1
char:1
+ Get-TeamFunSettings -GroupId a3f33284-82a5-4643-a43d-401f2568177c
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-TeamFunSettings], JsonSerializationException
+ FullyQualifiedErrorId : Newtonsoft.Json.JsonSerializationException,Microsoft.TeamsCmdlets.PowerShell.Custom.GetF
unSettings
We are actively investigating this issue and a fix is expected shortly. Note this commend is in beta so instability is not unexpected.
Maybe it's just very new but according to the documentation of the command "Allow all content" is not an option. (I do think it should be one, though)
https://learn.microsoft.com/en-us/powershell/module/teams/set-teamfunsettings

Why doesn't "Set-Item" work on Windows 7 PowerShell?

I am trying to install Windows 10 IoT on my Raspberry Pi 2. The PowerShell documentation tells me to put in this:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc>
However, when I put it into my Windows 7 PowerShell, this comes out:
At line:1 char:54
+ Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc>
+ ~
The '<' operator is reserved for future use.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported
How do I fix this?
You need to use quotes rather than < > around the name of the device (minwinpc)
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'minwinpc'

Resources