我正在尝试开发 Windows-Admin-Center-extension(Angular、Typescript、Powershell)
我收到错误“无法读取未定义的属性(读取'Powershell')
app.component.ts:
import { Component, OnDestroy, OnInit } from '@angular/core';
import { AppContextService, AuthorizationService, NavigationService } from '@microsoft/windows-admin-center-sdk/angular';
import { PowerShellScripts } from '../generated/powershell-scripts';
// import {Headers, Response} from '@angular/http';
import {Strings} from '../generated/strings';
import { Cim, Http, PowerShell, PowerShellSession } from '@microsoft/windows-admin-center-sdk/core';
import { Observable } from 'rxjs';
import {Shell} from 'node-powershell';
import {map, catchError} from 'rxjs/operators';
@Component({
selector: 'sme-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnDestroy, OnInit {
constructor(
public appContext: AppContextService, private navigationService: NavigationService) {
}
public session: PowerShellSession;
public ngOnInit() {
this.appContext.ngInit({ navigationService: this.navigationService });
// const session = this.appContext.powerShell.createSession('127.0.0.1');
alert ("ngoninit");
// const session = this.appContext.powerShell.createAutomaticSession('LAPTOP-5');
}
// ----------------------------------------------------------------------------------------------------------------------------------------
public greetuser() { return "Hallo"; }
// ----------------------------------------------------------------
public endlichAufruf(): Observable<any> {
// const session = this.appContextService.powerShell.createAutomaticSession('127.0.0.1');
let session = this.appContext.powerShell.createAutomaticSession("LAPTOP-5");
const script2 = PowerShell.createScript(PowerShellScripts.hello[0]);
return this.appContext.powerShell.run(this.session, script3); //<---------------------------------!!!!!!!!!!!!!!!!!!!!!!
}
// -------------------------------------------------------------------------------------------------------
public ngOnDestroy() {
this.session.dispose();
alert("ngdestroy");
this.appContext.ngDestroy();
}
}
我究竟做错了什么?