Usuário com melhor resposta
Como executar script .ps1?

Pergunta
-
Estou com um problema para executar um script no Exchange Management Shell.
Estou querendo executar um script .ps1 que baixei na internet para me listar o fluxo de emails no servidor. No blog onde baixei informa que eu devo digitar o seguinte comando: .\Fluxo_Email.ps1 <NOME_SERVIDOR> <NUMERO_HORAS>
Copiei o arquivo da internet e salvei na pasta:
C:\Program Files\Microsoft\Exchange Server\V14\Scripts
Junto de muitos outros scripts que tem nessa pasta.
Então executo o comando e me da o seguinte erro:
The term '.\Fluxo_Email.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Che
ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:18
+ .\Fluxo_Email.ps1 <<<< SNE0050 24
+ CategoryInfo : ObjectNotFound: (.\Fluxo_Email.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundExceptionAlguem sabe me dizer se é o caminho onde copiei o script que está errado ou o que pode ser?
Obrigado.
http://certificacoes.leaderconsult.com.br/lennon
Respostas
-
Ola Lennon
Tente usar o arquivo sem _ .
Jonathan Santos | http://jonathanrsantos.wordpress.com MCP | MCSA | MCSA Messaging | MCSE Messaging- Marcado como Resposta Jonathan SantosModerator terça-feira, 29 de março de 2011 12:11
Todas as Respostas
-
Olá Leonardo,
Tente fazer os seguintes testes:
- Copie o arquivo Fluxo_Email.ps1 para uma nova pasta C:\Temp
- Através do Exchange Management Shell verifique se o mesmo já está apontando para a unidade C:\ e mude para o C:\Temp com o comando cd Temp
- Utilize a tecla tab para navegar pelos arquivos até encontrar o arquivo .ps1 e após esse processo tecle Enter.
- Se o erro ocorrer novamente tente editar o arquivo .ps1 através do bloco de notas e verifique qual é o comando da linha 1 e poste aqui.Rafael Okamoto
- Sugerido como Resposta Thiago A. E. Carmo sexta-feira, 4 de fevereiro de 2011 11:00
-
Rafael,
fiz exatamente como vc disse.
E não funcionou.
O código é esse:
$dtQueryDT = [system.DateTime]::Now.AddHours(-($args[1]))
$dtQueryDTf = [system.DateTime]::Now
$InternalNum = 0
$InternalSize = 0$ExternalSentNum = 0
$ExternalSentSize = 0$ExternalRecNum = 0
$ExternalRecSize = 0$ServerName = $args[0]
$DomainHash = @{}
$msgIDArray = @{}
get-accepteddomain | ForEach-Object{
if ($_.DomainType -eq "Authoritative"){
$DomainHash.add($_.DomainName.SmtpDomain.ToString().ToLower(),1)
}}
Get-MessageTrackingLog -Server $ServerName -ResultSize Unlimited -Start $dtQueryDT -End $dtQueryDTf | ForEach-Object{
if ($_.EventID.ToString() -eq "SEND" -bor $_.EventID.ToString() -eq "RECEIVE"){
foreach($recp in $_.recipients){
if($recp.ToString() -ne ""){
$unkey = $recp.ToString() + $_.Sender.ToString() + $_.MessageId.ToString()
if ($msgIDArray.ContainsKey($unkey) -eq $false){
$msgIDArray.Add($unkey,1)
$recparray = $recp.split("@")
$sndArray = $_.Sender.split("@")
if ($_.Sender -ne ""){
if ($DomainHash.ContainsKey($recparray[1])){
if ($DomainHash.ContainsKey($sndArray[1])){
$InternalNum = $InternalNum + 1
$InternalSize = $InternalSize + $_.TotalBytes/1024
}
else{
$ExternalRecNum = $ExternalRecNum + 1
$ExternalRecSize = $ExternalRecSize + $_.TotalBytes/1024
}
}
else{
if ($DomainHash.ContainsKey($sndArray[1])){
$ExternalSentNum = $ExternalSentNum + 1
$ExternalSentSize = $ExternalSentSize + $_.TotalBytes/1024
}
}
}
}
}
}
}}
"Sent/Recieved Internally Number : " + $InternalNum
"Sent/Recieved Internally Size : " + [math]::round($InternalSize/1024,2)
"Externally Sent Number : " + $ExternalSentNum
"Externally Sent Size : " + [math]::round($ExternalSentSize/1024,2)
"Externally Recieved Number : " + $ExternalRecNum
"Externally Recieved Size : " + [math]::round($ExternalRecSize/1024,2)
http://certificacoes.leaderconsult.com.br/lennon -
Ola Lennon
Tente usar o arquivo sem _ .
Jonathan Santos | http://jonathanrsantos.wordpress.com MCP | MCSA | MCSA Messaging | MCSE Messaging- Marcado como Resposta Jonathan SantosModerator terça-feira, 29 de março de 2011 12:11
-